js小技巧-判断表格是否被选中

来源:互联网 发布:3米距离买多大电视知乎 编辑:程序博客网 时间:2024/06/05 04:52
js:
$(function(){    var myRows = $('table tr').click(function(){        alert('Row #' +myRows.index(this) + ' value=' + $(this).children('td').text());    });});


html:
<table width="300" border="1" cellspacing="1" cellpadding="2">  <tr>    <td width="150">0-1</td>    <td width="150">0-2</td>  </tr>  <tr>    <td>1-1</td>    <td>1-2</td>  </tr></table>


0 0
原创粉丝点击