Aariba Aariba - 2 months ago 7
HTML Question

Find Text from content then hide

I am trying hide

specific
Text elements from content by jquery.

HTML:

<div id="name">
Trying hide specific Text elements from content.
</div>


I want this:

<div id="name">
Trying hide <p style="display: none;">specific</p> Text elements from content.
</div>


Or any others simple solution by jquery?

Answer

somthing simple like

var nameText = $('#name').text();
var newText = nameText.replace('specific','<p style="display:none">specific</p>');
$('#name').html(newText) // use html() here, not text()