Home > Web Front-end > JS Tutorial > jQuery method to replace the specified string in the specified element_jquery

jQuery method to replace the specified string in the specified element_jquery

WBOY
Release: 2016-05-16 16:09:05
Original
1468 people have browsed it

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>
Copy after login

The jQuery part is as follows:

var el = $('#content'); 
el.html(el.html().replace(/jb51/ig, ''));
Copy after login

I hope this article will be helpful to everyone’s jQuery programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template