日期:2014-05-17  浏览次数:20890 次

如何根据td获取同行另一个td的值
<form>
<table>
<tr>
  <th width ="5%"><input type ="checkbox" name ="check" value ="${keyword.id }"/></th>  
<td align ="center">${keyword.send }</td>
<td align ="center"><a href ="javascript:showcontent(this)">${keyword.title} </a></td>
<td align ="center">${keyword.date }</td>
</tr>
</table>
</form>


点击链接<a href ="javascript:showcontent(this)"> showcontent函数中如何取得value ="${keyword.id }的值?

------解决方案--------------------
jquery选取
------解决方案--------------------
$("input[type=checkbox]:checked").val();
这样就可以获取到了
------解决方案--------------------
<form>
<table>
<tr>
<th width ="5%"><input id="check_${keyword.id }" type ="checkbox" name ="check" value ="${keyword.id }"/></th>
<td align ="center">${keyword.send }</td>
<td align ="center"><a href ="javascript:showcontent(this, 'check_${keyword.id }')">${keyword.title} </a></td>
<td align ="center">${keyword.date }</td>
</tr>
</table>
</form>


直接再加个参数呀,后面的那个参数就直接是前面的checkbox的ID咯
------解决方案--------------------
直接传参啊showcontent('${keyword.id }')
或者用jquery
$('input[name="check"]').val();
------解决方案--------------------
探讨

$("input[type=checkbox]:checked").val();
这样就可以获取到了

------解决方案--------------------
根据楼上的
var tr = td.parentNode;
alert(tr.childNodes[2].innerHtml);
------解决方案--------------------
探讨
直接传参啊showcontent('${keyword.id }')
或者用jquery
$('input[name="check"]').val();