Jquery 控制table中的checkbox 相关选中事件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="Javascript/jquery-1.12.3.min.js" type="text/javascript"></script> <style type="text/css"> #d1{ width:500px; height:300px; background-color:Gray;} #d1_1,#d1_2,#d1_3{ width:300px; height:50px; background-color:Green;} #d1_1_1{ width:150px; height:15px; background-color:Lime;} #d1_1_2{ width:150px; height:15px; background-color:Lime;} #s_1{ display:block; width:150px; height:10px; background-color:Red; padding:2px;} </style> </head> <body> <table id="tb1"> <tr><td><input type="checkbox" value="1" /></td><td><input type="text" value="text1" /></td><td></td></tr> <tr><td><input type="checkbox" value="2" /></td><td><input type="text" value="text2" /></td><td></td></tr> <tr><td><input type="checkbox" value="3" /></td><td><input type="text" value="text3"/></td><td></td></tr> <tr><td><input type="checkbox" value="4" /></td><td><input type="text" value="text4"/></td><td></td></tr> </table> <input type="button" id="btn1" value="test1" /> <input type="button" id="btn2" value="test2" /> <script type="text/javascript"> $(function () { // $("#tb1").find(":checkbox").each(function () { $(this).change(function () { if ($(this).is(':checked')) { //alert($(this).val()); var temp = $(this).parent().next().children().val(); alert(temp); } }) }) }) </script> </body> </html>
You are never too old to set another goal or to dream a new dream!!!