【发布时间】:2013-10-05 17:12:30
【问题描述】:
我有一些简单的 jquery 代码,我用它来动态创建 this page 而不是手动创建。这是我的代码
循环
for ( var i = 0; i < links.length; i++ ) {
$("#programs").append(
$("li")
.html("div")
.html("a", {
href: links[i] + ".exe"
})
.html("img", {
src: icons[i]
})
.html("p")
.html(captions[i])
);
}
数组声明
var links = ["pictureVeiwer","maze","firefoxPrank"];
var icons = ["firefox-icon.gif","maze.jpg","imageVeiwer.jpg"];
var captions = ["Cute Firfox prank","Cool maze","Program to veiw pictures... kinda useless in 2013"];
我认为我的语法有点不对劲,我之前使用过类似的代码,但不是在循环中。我做错了什么,我该怎么做?
【问题讨论】:
标签: jquery html for-loop append innerhtml