一:
$(html,[ownerDocument])
示例:
$("<div><p>Hello</p></div>").appendTo("body");
二:$(html,props)
示例:
$("<input>", {
type: "text",
val: "Test",
focusin: function() {
$(this).addClass("active");
},
focusout: function() {
$(this).removeClass("active");
}
}).appendTo("form");
http://jquery.cuishifeng.cn/jQuery_html_ownerDocument.html
本文介绍了如何使用jQuery来动态创建HTML元素并设置属性,包括基本的元素创建、属性设置及事件绑定,并展示了如何将这些元素追加到指定的DOM节点。
1643

被折叠的 条评论
为什么被折叠?



