I am trying to remove a 'h3' tag from a header list selecting it by text. For example if I have:
html:
<h3>NO CHANGE</h3>
<h3>h3 to be removed</h3>
<h3>NO CHANGE</h3>
<h3>NO CHANGE</h3>
<h3>NO CHANGE</h3>
jQuery:
var h3_text_remove = $('h3').text();
if (h3_text_remove == 'h3 to be removed'){
$('h3').remove();
//console.log (h3_text_remove);
}
How can I remove just the header with text 'h3 to be removed'?
fiddle: http://jsfiddle.net/q2nb08t6/7/
You can use contains() selector
Fiddle