| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 3 | <head> |
|---|
| 4 | <title>jquery tests - 1.3b2 - live + html manipulation</title> |
|---|
| 5 | <script src="../dist/jquery.js" type="text/javascript" charset="utf-8"></script> |
|---|
| 6 | <!-- script src="jquery.js" type="text/javascript" charset="utf-8"></script--> |
|---|
| 7 | <script type="text/javascript" charset="utf-8"> |
|---|
| 8 | var livetimes1 = 0; |
|---|
| 9 | var livetimes2 = 0; |
|---|
| 10 | var clicktimes = 0; |
|---|
| 11 | var modifyDom = true; |
|---|
| 12 | $('a.test').live('click', function(){ |
|---|
| 13 | $('#times1').html(++livetimes1); |
|---|
| 14 | if(modifyDom) { |
|---|
| 15 | $(this).html('<span>Click Me</span>'); |
|---|
| 16 | } |
|---|
| 17 | return false; |
|---|
| 18 | }); |
|---|
| 19 | $('a.test').live('click', function(){ |
|---|
| 20 | $('#times2').html(++livetimes2); |
|---|
| 21 | return false; |
|---|
| 22 | }); |
|---|
| 23 | $(function(){ |
|---|
| 24 | $('a.test').click(function(){ |
|---|
| 25 | $('#times3').html(++clicktimes); |
|---|
| 26 | }); |
|---|
| 27 | $('#toggle').click(function(){ |
|---|
| 28 | $('#mod').html(''+(modifyDom = !modifyDom)); |
|---|
| 29 | }); |
|---|
| 30 | }); |
|---|
| 31 | </script> |
|---|
| 32 | <style type="text/css" media="screen"> |
|---|
| 33 | </style> |
|---|
| 34 | </head> |
|---|
| 35 | <body> |
|---|
| 36 | <p><a href="#" class="test">Click Me</a></p> |
|---|
| 37 | <p> |
|---|
| 38 | 1st live() clicks: <span id="times1">0</span><br/> |
|---|
| 39 | 2nd live() clicks: <span id="times2">0</span><br/> |
|---|
| 40 | click() clicks: <span id="times3">0</span> |
|---|
| 41 | </p> |
|---|
| 42 | <p>Modify DOM: <span id="mod">true</span> <a href="#" id="toggle">toggle</a></p> |
|---|
| 43 | </body> |
|---|
| 44 | </html> |
|---|