The simplest method
When you click the button, the p element is hidden or displayed:
| The code is as follows: |
Copy code |
$ ("Button"). live ("click", function (){ $ ("P"). slideToggle (); }); |
After jQuery dynamically generates an HTML element, if there is a mouse CLICK event in the element set.
In this case, the. live () method is used to make the generated dynamic elements remain effective after the page is loaded, so that the mouse click event takes effect.
| The code is as follows: |
Copy code |
JQuery (document). ready (function (){ Var contentTR = $ ('. info tr: eq(0w.'{.html (); Var e = 0; $ ('. Addrow'). click (function (){ E = e + 1; $ (". Info. addrow"). parent (). parent (). before ('<tr>' + contentTR + '</tr> '); $ (". Info tr: eq ("+ e + ")"). find ("input: eq (0 )"). attr ("name", "a" + e ); $ (". Info tr: eq ("+ e + ")"). find ("input: eq (1 )"). attr ("name", "B" + e ); $ (". Info tr: eq ("+ e + ")"). find ("select: eq (0 )"). attr ("name", "c" + e ); $ (". Info tr: eq ("+ e + ")"). find ("input: eq (2 )"). attr ("name", "d" + e ); $ (". Info tr: eq ("+ e + ")"). find ("input: eq (3 )"). attr ("name", "f" + e ); }); $ ('. Del'). live ('click', function (){ $ (This). parent (). parent (). remove (); }); }); |