How to use the jquery replaceall method
This article mainly introduces the relevant knowledge of how to use the jquery replaceall method, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this jquery replaceall method. Let's take a look at it.
The jquery replaceAll () method is used to replace the selected element with a new HTML element, with the syntax "$(content) .replaceAll (selector)"; the parameter "selector" specifies the selected element, and "content" specifies the replacement content that contains the HTML tag.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Jquery replaceall () method
The replaceAll () method replaces the selected element with the new HTML element. Syntax format:
The $(content) .replaceAll (selector) parameter is required to describe content. Specifies what to insert (must contain HTML tags). Selector is required. Specify which element will be replaced.
It can be simplified to: $(A) .replaceAll (B), which means replacing B element with An element.
Example 1: replace the strong element with the an element
$(function () {$("button") .click (function () {$('') .replaceAll ("strong");}) jQuery tutorial
Hide textarea
Example 2: replace the last p element with the span element
$(function () {$("button") .click (function () {$("Hello world!") .replaceAll ("p:last");}))
This is a paragraph.
This is another paragraph.
Hide textarea
Description:
The last selector selects the last element, which is only used to select a single element
The most common usage: use with other selectors to select the last element in the specified combination (such as the example above).
This is the end of the article on "how to use the jquery replaceall method". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to use the jquery replaceall method". If you want to learn more, you are welcome to follow the industry information channel.