<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<body>
<div id= "Search_conditions" >
<div class= "Condition" >
<a onclick= "addcondition (This, ' #search_conditions ')" >+</a>
<input/>
</div>
</div>
<script src= "Js/jquery-1.8.2.min.js" ></script>
<script>
function Addcondition (ths,container) {
ths here refers to <a></a> tags
var CP = $ (THS). Parent (). Clone ();
Clone label <a></a> parent tag and assign to variable CP
Cp.children (': First '). Text ('-'). attr (' onclick ', "removecondition (This, ' #search_conditions ')");
Gets the parent tag the contents of the first child a tag and then modifies the content to '-' via text,
Then modify the onclick binding function by attr addcondition to Removecondition
$ (' #search_conditions '). Append (CP);
Append the cloned result CP to the parent tag
Cp.appendto (' #search_conditions ')
}
function Removecondition (ths,container) {
The ths parameter represents the label <a></a>, so the parent tag of label A is <div class= "condition" ></DIV>
Then delete the entire parent tag to implement the ability to delete the entire form
$ (THS). Parent (). remove ();
}
</script>
</body>
Demo Effect:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/87/19/wKiom1fT4UjRZ1TyAAAM6cnPS38122.png "title=" Add delete row. png "alt=" Wkiom1ft4ujrz1tyaaam6cnps38122.png "/>
This article from "Flat Light is true" blog, please be sure to keep this source http://ucode.blog.51cto.com/10837891/1851434
Add form processing to delete a form line