Devamol
Devamol

Reputation: 1

How can I replace or remove a special character in text with Jquery

I want to replace or remove this special character ">" from my text with Jquery.

ex. <div class="test">></div>.

Thank you in advance.

Upvotes: 0

Views: 41

Answers (1)

Venkata Krishna
Venkata Krishna

Reputation: 15122

Just empty the text of the div.

$('div.test').text('');

or If you want to keep the other text intact, use like below.

var $div = $('div.test');
var str = $div.text(); 
$div.text(str.replace(/>/g, "")); //replaces all occurrences of > and assign again

Upvotes: 1

Related Questions