1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
---|
5 | <title>Is it a BUG in jQuery 1.3?</title> |
---|
6 | <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script> |
---|
7 | <script language="javascript"> |
---|
8 | $(function($){ |
---|
9 | |
---|
10 | //Insert |
---|
11 | $('#insert-row').click(function(){ |
---|
12 | $('table').append($('<tr><td><input type="text" value="" /></td></tr>')); |
---|
13 | }); |
---|
14 | |
---|
15 | |
---|
16 | //Input click |
---|
17 | $('table td input').live('click', function(ev){ |
---|
18 | console.log('input "click" event'); |
---|
19 | }); |
---|
20 | |
---|
21 | //TD click |
---|
22 | $('table td').live('click', function(ev){ |
---|
23 | |
---|
24 | //Ignores if is a bubbled event |
---|
25 | if(ev.target != this){ return false; } |
---|
26 | |
---|
27 | console.group('td "click" event'); |
---|
28 | if($('#triggerHandler').is(':checked')){ |
---|
29 | $(this).find('input').triggerHandler('click'); |
---|
30 | console.log('but where is the input "click" event?'); |
---|
31 | } else { |
---|
32 | $(this).find('input').trigger('click'); |
---|
33 | } |
---|
34 | console.groupEnd(); |
---|
35 | |
---|
36 | }); |
---|
37 | |
---|
38 | }); |
---|
39 | </script> |
---|
40 | </head> |
---|
41 | <body> |
---|
42 | <table width="200" border="1"> |
---|
43 | <tr> |
---|
44 | <th id="insert-row">Insert Row</th> |
---|
45 | </tr> |
---|
46 | </table> |
---|
47 | <br/> |
---|
48 | <input type="checkbox" id="triggerHandler" value="yes" checked="checked" /><label for="triggerHandler">Use triggerHandler</label> |
---|
49 | </body> |
---|
50 | </html> |
---|