I have got a jQuery var that contains HTML that I’m appending to a page.
I need to remove a HTML element before I append it to the page but I can’t seem to filter it.
for example the variable contains;
<div class="block1"></div>
<div class="block2"></div>
I have tried filtering like this before I append:
var mydata = $(mydata).filter('.block1');
and
var mydata = mydata.filter('.block1');
but none of these work. Any suggestions?
Filter applied directly to string sometimes give string result, its safe to add element to DOM and then apply filters. Assign html to some temporary element in the DOM, Get the filtered items from this temporary element and assign it to desired element.