Home > Article > Web Front-end > jQuery method to replace the specified string in the specified element_jquery
The example in this article describes how jQuery replaces the specified string in the specified element. Share it with everyone for your reference. The details are as follows:
This JS code can replace the string of the element content with the specified id. For example, the code in the west replaces the jb51 string in the id=content element with the empty character
The html part is as follows:
<div id=content>welcome to jb51</div>
The jQuery part is as follows:
var el = $('#content'); el.html(el.html().replace(/jb51/ig, ''));
I hope this article will be helpful to everyone’s jQuery programming.