Home  >  Article  >  Web Front-end  >  Code to add and delete elements using JQUERY_jquery

Code to add and delete elements using JQUERY_jquery

WBOY
WBOYOriginal
2016-05-16 17:56:181093browse

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'/>








Statement:
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