[英]how to append the data using jquery?
我需要使用dom将值添加到跨度中。 但是现在我正在使用字符串操作。 如何将其更改为dom或附加值。 我需要使用dom获取HTML格式的返回值。
将layer.id定义为一些文本,这将在所有span元素内容中被替换
$.each($("span"),function(){
$(this).html(layer.id);
});
谢谢
您可以像下面这样追加:
$('.ClassName').append('<p>Test</p>');
$('#id').after('<p>Test</p>');
$('#id').before('<p>Test</p>');
试试这个:
$("<li class='" + liClass + "'>" + preElement +
"<label for='" + layer.id + "'>" + layer.name + "</label>").appendTo('ul.class');
//----------^^^^^
// use the id
// or class of
//the specific ul
使用appendTo()
代替返回并将其附加到您的元素。
(as i see you are returning li then append it to the ul)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.