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

Jquery dynamically adds and deletes page node elements sample code_jquery

WBOY
Release: 2016-05-16 16:44:22
Original
1132 people have browsed it

Usually we will select a certain condition, then add it, and then execute it after accumulating multiple conditions.

Without further ado, let’s get straight to the code!

Copy code The code is as follows:




Jquery dynamically adds and deletes page nodes


<script> <br>$(function(){//After the page is loaded, execute <br>$("input").click(function() {//Add operation<br>var getval=$("select").val();//Get the currently selected select value<br>$("p").before('<li>' getval ' <span> live("click",function(){//Event handlers attached through the live() method apply to current and future elements matching the selector (such as new elements created by scripts) <br>$(this). parent().remove();//Remove the parent element of the currently clicked element <br>}); <br></script>













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