How to remove code from HTML string?
I have a variable that has this string:
<DIV><SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt">[If the confirmation is active the subscriber will receive this email after succesfully confirming. If not, this will be the first and only email he will receive.]</SPAN></DIV>
<p align=center>
<input class=fieldbox10 type = 'button' name = 'button' value = 'Close' onclick = "window.close()">
</p>
How do开发者_开发技巧 I remove the below string without worrying about spaces via Javascript (or jQuery)?
<p align=center>
<input class=fieldbox10 type = 'button' name = 'button' value = 'Close' onclick = "window.close()">
</p>
Maybe this?
$(html).remove('p');
If your var was myString
you can do this:
var temp = $("<div />").append(myString);
temp.find('p:has(input[value=Close])').remove('p');
myString = temp.html();
You can see a working demo here
精彩评论