您的位置:首页 > 其它

td中通过button绑定click事件实现跳转,以及获取同一table中另一td的值

2017-07-05 11:21 302 查看
1、通过button绑定事件跳转到同一页面的其他div

例:

js页面

<table id = "tableid">
<tr>
<td id = "rcode">"123456"</td>
<td><button type="button" id="buttonid" onclick="javascript:toManager(this)"></button></td>
</tr>
</table>
<div id ="manage">跳转到的位置</div>


javascript脚本

<script type="text/javascript">
function toManager(r){
window.location.hash = "#manager";
var clickRow = r.parentNode.parentNode.rowIndex;//获取button行所在table的index
alert(clickRow);
var rcode = $(r).parent().parent().find("#rcode").val();  //rcode为另一td的id
alert(rcode);
}
</script>


js页面需要引入jquery的插件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐