Vishnu Prasad
Vishnu Prasad

Reputation: 727

How to remove a word/string from div content using javascript

My div contains words 'abc def ghi fij' etc like this <div id='elements'>abc def ghi fij..</div> How can i remove a certain word from it and place the remaining word in same div like removing "def ghi" and make new content to div like <div id='elements'>abc fij..</div> using javascript Thanks in advance

Upvotes: 0

Views: 2013

Answers (1)

Amit Joki
Amit Joki

Reputation: 59232

Well you can use function overload of text

$('#elements').text(function(t){
    return t.replace("def ghi", "");
});

Upvotes: 2

Related Questions