日期:2014-05-16 浏览次数:20369 次
<html> <head> <script src="jquery.js"></script> </head> <body> <table id="mytable" border="1"> <tbody> <tr><td id="1">1</td><td id="7">7</td></tr> <tr><td id="2"><input type="text" value="xxx" /></td><td id="8">8</td></tr> <tr><td id="3"><input type="button" value="yyy" /></td></tr> <tr><td id="4">4</td></tr> <tr><td id="5">5</td></tr> <tr><td id="6">6</td></tr> </tbody> </table> <script> var td_query=$("tbody>tr>td:not(:has(input))"); //alert(td_query.length); // 输出6 $("tbody>tr>td:not(:has(input))").dblclick(function(){ $(this).html("<input type='text' value='test' />"); alert(td_query.length); }); </script> </body> </html>
$("tbody>tr>td:not(:has(input))").one('dbclick',function(){ $(this).html("<input type='text' value='test' />"); alert(td_query.length); });