If i have a js variable that contains some html tags, how can I determine the number of tags inside the variable? Something like this:
contents = "<p>something</p><p>something else</p>";
$(contents).find("p").length > 2;
Basically, I’m doing a $(".someClass").each() and iterating through a bunch of elements – when I encounter a <p> tag I’m putting it in the variable with .html() and now I need to know whats inside the variable to make another decision but my approach above isn’t working.
Change
.findto.filter..findsearches children, but in your string, all the<p>tags are parents, they aren’t children of anything.