Search code examples
javascriptjquerydommustache

select the element not equal `#text`


After use mustache render I try to get the dom just append, how do I select only li.data?
or How to make mustache return appendedDom not include #text?

..
var html = Mustache.to_html(this.template.data, response);
var appendedDom = $(html).appendTo(this.el.container);

console.log(appendedDom);


>> console.log
<li class=​"data">​…​</li>​
#text

I tried $(appendedDom+'.data') this not work ,
Error: Syntax error, unrecognized expression: [object Object].data

  console.log($(appendedDom+'.data'));

Solution

  • It seems that appendedDom is just a set of elements, so you should be able to filter that:

    $(appendedDom).filter('.data-control-list')