日期:2014-05-16 浏览次数:20507 次
<html> <head> <script type="text/javascript"> function window_onload() { for(var i=0;i<document.forms[0].option.length;i++) { if(document.forms[0].option[i].checked) { var temp = document.forms[0].option[i].value; alert(temp); var team = document.forms[0].option[i]; var text = team.parent('td').parent('tr').find('td').eq(1).text(); alert(text); } } } </script> </head> <form method="post" name="form_gotopage" > <div id="menuBarContainer"> </div> <table id="report_table" border=1 cellspacing=0 cellpadding=0> <thead> <tr> <th width="15" style="padding-left:3px;"><input type="checkbox" id="option"></th> <th>test</th> <th>tkkkkk</th> <th>yyyyy</th> </tr> </thead> <tr> <td align="center"><input type="checkbox" name="id[]" id="option" value="1 line and 1 column "></td> <td>hello</td> <td>word</td> <td>good</td> </tr> <tr> <td align="center"><input type="checkbox" name="id[]" id="option" value="2 line and 2 column "></td> <td>hello2</td> <td>word2</td> <td>good2</td> </tr> </table> </form> <input type='button' value='clicke me' onclick='return window_onload()'> </body> </html>
<script type="text/javascript"> function window_onload() { alert($("input:checked").parent().siblings().text()); } </script>
------解决方案--------------------
function window_onload() { for(var i=0;i<document.forms[0].option.length;i++) { if(document.forms[0].option[i].checked) { var temp = document.forms[0].option[i].value; //alert(temp); var team = document.forms[0].option[i]; var text = ""; var tr = team.parentNode.parentNode;//得到TR var tds = tr.childNodes; var flag = 0; for(var j=0; j< tds.length;j++){