- function showCol(){
- var check=$("input[name='one']:checked");//选中的复选框
- check.each(function(){
- var row=$(this).parent("td").parent("tr");
- var name=row.find("[name='name']").html();//注意html()和val()
- var age=row.find("[name='age']").html();
- console.info(name+":"+age);
- });
- }
JSP页面
-
- <table>
- <tr>
- <td><input name='one' type='checkbox' οnclick='doCheckOne(this)' value='1' checked='checked'/></td>
- <td name='name'>小花</td>
- <td name='age'>18</td>
- </tr>
- <tr>
- <td><input name='one' type='checkbox' οnclick='doCheckOne(this)' value='1' checked='checked'/></td>
- <td name='name'>小草</td>
- <td name='age'>20</td>
- </tr>
- <tr>
- <td><input name='one' type='checkbox' οnclick='doCheckOne(this)' value='1' checked='checked'/></td>
- <td name='name'>小树</td>
- <td name='age'>19</td>
- </tr>
- </table>