Resolves an invalid method for element events added using jquery with append

Source: Internet
Author: User

<HTML><Head><Scripttype= "Text/javascript"src= "/jquery/jquery.js"></Script><Scripttype= "Text/javascript">$ (document). Ready (function(){  $("Button"). Live ("Click",function(){    $("P"). Slidetoggle (); });});</Script></Head><Body><P>This is a paragraph.</P><Button>Please click here</Button></Body></HTML>

But with the jquery version upgrade, since jquery 1.9 and above have been unable to use live, then there is no way, no, for the jQuery1.9 version and above can use on, the effect is equivalent to live. How to use the following on

<Script>$ (document). On ("Click", ". Waiting-save", function() {$ ( This). HTML ('@T ("Saving ...")') $ ( This). attr ("Disabled", "");});</Script>

The entire code example is:

<!DOCTYPE HTML><HTML><Head>    <title></title>    <MetaCharSet= "Utf-8"/></Head><Body><Div>   <formAction=" "Method=" " >    <Divclass= "List">        <Divclass= "Addlist">Division:<Select>                <option>Division</option>                <option>Division 1</option>                <option>Division 2</option>            </Select>Quantity:<inputtype= "text"value= "123"/>            <!--<span class= "Add" > Add </span> -
             <inputtype= "button"value= "Add"class= "Add"/>        </Div>    </Div>    </form></Div></Body><Scripttype= "Text/javascript"src= "./js/jquery-2.1.4.min.js"></Script><Scripttype= "Text/javascript">    $(function(){        //global variable iI=0; $(". Add"). Click (function() {              $(". List"). Append (function(){                    return '<div class= "Dellist'+I+'> Division: <select><option> Division </option><option> Division 1</option><option> Division 2< Number of/option></select>: <input type= "text" value= "123"/><input type= "button" class= "del" value= "delete"/ > </div>';              }); I++;         }); $ (document). On ("Click", ". del", function () {            $( This). Parent (). remove ();    }); })</Script></HTML>
Attention:
1.button problem
<input type= "button" value= "Add"
class= "Add" > Add </button>
The Dellist div will flash and disappear after the flash, and cannot be displayed on the page.
2.input tag closure problem.
When editing the page, remember that the label should be closed, if not closed, there will be problems.

Reference URL:
http://so.xiaohuihui.net/?a=url&k=6c98d343&u= Ahr0cdovl3d3dy5idwj1a28uy29tl2luzm9kzxrhawwtntcwmjgylmh0bww=&[email protected]ql5lu25peg5pwi55qe5pa55rovia= =&s=anf1zxj5igfwcgvuzcdml6dmlyg=

Resolves an invalid method for element events added using jquery with append

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.