<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