Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Specific Content from div with jQuery?

Can you remove specific content from an element with jQuery?

So for example, if I had

<p>Hello, this is a test</p> 

could I turn it into

<p>this is a test</p>

with jQuery (or any Javascript)

Please keep in mind that I just want to remove the "Hello, " so

$(p).innerHTML("this is a test");

wont work

like image 783
Shahmeer Navid Avatar asked Dec 12 '22 09:12

Shahmeer Navid


1 Answers

var str = $('p').text()
str.replace('Hello,','');
$('p').text(str);

For more information visit: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace

like image 136
Simon Arnold Avatar answered Dec 25 '22 00:12

Simon Arnold