Add form processing to delete a form line

Source: Internet
Author: User

<! 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.