$('#clicker').click(function () {
collegeArray = ["Harvard", "Yale", "Princeton"];
alert(collegeArray.length);
for (var i = 0; i < collegeArray.length; i++) {
var divIdName = 'college' + i + 'Div'; //manuplating name of each div generated dynamically
var newdiv = document.createElement('div')
.setAttribute('id', divIdName) //setting the name of each div created dynamically
.html('<p>' + collegeArray.toString() + '</p>')
appendTo($(#'survey'));
}
});
每次按下点击器按钮时,上面的代码都应该附加 html,但它不起作用。我不确定我在这里做错了什么