我有一组元素,我希望将它们放入一个 jquery 对象中。jquery.add() 似乎没有将元素添加到我的 jquery 对象中。我有控制台日志显示我添加的东西确实是 html 元素,但它们仍然没有添加到我做错了什么?
我的代码:
console.log('iterating')
console.log(content)
//add the content into the jquery item, and then we can load it into the qtip
_.each(additionalContent, function(value, element, list){
console.log('adding')
console.log(value)
console.log(content.length)
content.add(value) //trying content.add($(value)) gives the same result/output
console.log(content.length)
})
console.log('asdf')
console.log(content.length)
console.log(content)
====================== 打印以下内容:
iterating
[p.nonVendor unselectable, selector: "", context: undefined, jquery: "1.9.1", constructor: function, init: function…]
adding
<button class type="button" data-loading-text="OK" style="text-align: center; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: normal; font-family: arial; color: rgb(255, 255, 255); background-color: rgb(0, 0, 255); z-index: 2; display: inline; left: auto; top: auto; width: 35.77777862548828px; height: 17.777777671813965px;">OK</button>
1
1
adding
<button class type="button" data-loading-text="Cancel" style="text-align: center; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: normal; font-family: arial; color: rgb(255, 255, 255); background-color: rgb(0, 0, 255); z-index: 2; display: inline; left: auto; top: auto; width: 35.77777862548828px; height: 17.777777671813965px;">Cancel</button>
1
1
asdf
1
[p.nonVendor unselectable, selector: "", context: undefined, jquery: "1.9.1", constructor: function, init: function…]