If I have a text like this:
<p> </p> <p>this is the real text</p> <p> </p> <p>more</p>
I need the jQuery part that will replace the first instance with only <p> </p> by '..
Thus, the result after the call should be:
<p>this is the real text</p> <p> </p> <p>more</p>
But if the first line is not <p> </p> , then the call should not do anything.
EDIT
I tried to implement a solution from @Joey C., but I can't get it to work. There is simply no to remove.
var myHtml = "<p>abc</p><p>next para</p>"; var newElement = $(myHtml); if ($(newElement).first("p").text() == "abc") { $(newElement).first("p").remove(); } alert($(myHtml).text());
source share