使用jQuery从Array到Div的图像和文本? [英] Images and Text from Array into Divs with jQuery?
本文介绍了使用jQuery从Array到Div的图像和文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它返回 / dev / null
,为什么?我尝试用图像和一些文本填充新的div。
It returns /dev/null
, why? I try to populate new divs with an image and some text.
<html>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<body>
<div id='pitch'></div>
</body>
<script>
var v= new Array();
v[0] = new Array('h.png','Happy1!');
v[1] = new Array('hh.png','Happyy2!');
v[2] = new Array('hhh.png','Happyyy3!');
$(v).each(function(index,el){
$(div.pitch).append("<div><img src='"+el[0]+"'>"+el[1]+"</div>");
});
</script>
推荐答案
你缺少选择器引号''和id hash
You are missing the selector quotes '' and id hash
$('div#pitch').append("<div><img src='"+el[0]+"'>"+el[1]+"</div>");
这篇关于使用jQuery从Array到Div的图像和文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文