I am wondering can this be done
var b = '<span id="test">hi </span> <p>some text </p>';
So now I want to get the hi from this variable can I somehow do a selector on b?
If it was on the page I could do $('#test').html();
Can this be done but passing jquery the contents of b?
Sure, just pass it in and drop your selector into
.filter():If element you’re looking for is contained within some root element in your string of HTML, use
.find()instead.