这可能是一个简单的答案,但我试图添加一个dom创建的元素(即document.createElement(...)
)到jQuery Selector。jQuery添加DOM元素
jQuery有功能的大拼盘添加HTML
- 的.html(htmlString)
- .append(htmlString)
- .prepend(htmlString)
但我想做的就是加个dom OBJECT
var myFancyDiv = document.createElement("div");
myFancyDiv.setAttribute("id", "FancyDiv");
// This is the theoretical function im looking for.
$("#SomeOtherDiv").htmlDom(myFancyDiv);
你不不需要用附加的jQuery来包装DOM对象。可以做'$(“#SomeOtherDiv”)。append(myFancyDiv)' – Anurag 2010-04-21 22:00:23