[英]appending syntax for appending div
function Build(div_id) {
var con = '<div>';
$.each(div_id, function () {
con += 'iuuuuuuuuuuuuuuuuuuuyy' + '<br/><br/>';
});
con += '</div>';
$('#' + div_id).append(con);
}
on my client aspx file I have lots of divs.在我的客户端 aspx 文件中,我有很多 div。 every div has id number `<div id='somenumber...每个 div 都有 id 号 `<div id='somenumber...
the function above gets div_id and needs to append data into specific div.上面的函数获取 div_id 并需要将数据附加到特定的 div 中。
$('#' + div_id).append(con);
in this line I'm trying to append con
which has the data that I want to append and div_id
is the div id number which I want to append to.在这一行中,我试图附加con
,其中包含要附加的数据,而div_id
是要附加到的 div id 编号。
尝试将最后一行更改为
$('#' + div_id).append($(con));
As you iterate over the items, I guess items is some kind of array.当您遍历项目时,我猜项目是某种数组。 This would mean you have to do something like this:这意味着你必须做这样的事情:
$.each(items, function (n,value) {
$('#' + value).append(con);
});
function Build(div_id) {
var con = $("<div/>");
$.each(items, function () {
con.append('iuuuuuuuuuuuuuuuuuuuyy' + '<br/><br/>');
});
$('#' + div_id).append(con);
}
http://jsfiddle.net/3nigma/ZcnMK/ http://jsfiddle.net/3nigma/ZcnMK/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.