Home > Web Front-end > JS Tutorial > body text

Code to add and delete elements using JQUERY_jquery

WBOY
Release: 2016-05-16 17:56:18
Original
1100 people have browsed it

Use JQUERY to add and delete elements
JQuery has methods to add and delete elements.
Mainly divided into internal insertion, external insertion, wrapping, replacement and deletion.
Main method of internal insertion:
append(content) Append content to each matching element.
prepend(content) prepends content inside each matching element.
External insertion:
after(content) Inserts content after each matching element.
before(content) inserts content before each matching element.
Delete:
empty() deletes all child nodes in the matched element set.
remove([expr]) Removes all matching elements from the DOM.

The following example is to click the add button to insert a new row in the last row of the table
and then click the delete button to delete the last row


Copy code The code is as follows:





Add and delete table elements
< ;script type="text/javascript" src="jquery-1.4.2.min.js">










First grid < input type='text'/>








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