Examine the following:
<div class='item'>
Here is some sample text.
<a class='item-of-interest' href='#'>add</a>
</div>
The “Here is some sample text” might be there but not always. What you then want to check is whether the inner html of $(‘.item’) is equal to the link item alone. Since .html() returns a string representation of the html and $(‘.item-of-interest’) returns a jQuery object, you will have to find a way to convert this object to a string representation. The easiest way to do this is by using the following code:
var html = $('<div>').append($('.item-of-interest').clone()).html();
You temporarily create an element to which you append the .item-of-interest, then you request the inner html of it.