当我对附加到父 div 的元素执行 console.log 时,怎么会出现一堆回车节点。有没有办法删除它,因为当我尝试向它们添加一些 css 时,它们会破坏应用程序。
这是我的设置。我正在使用下划线模板来创建我的 html。tmpl 一切正常。
var tmpl = $( template({items : list}) );
var items = $(_.filter(tmpl, function(item){
return ! $item.hasClass('pin');
}));
var domItems = items.appendTo($('.container'));
这是日志
domItems =
[<TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item, <TextNode textContent="\n \n ">, div.item]
我只希望它返回 div.item 元素