how to get selected table row values using jquery?

2020-04-17 07:33发布

I need to get the selected row values in a table using jquery by clicking on the row or a link.. i am new to jquery ,,anybody help me with sample code..that would help me greately. Thanks in advance

标签: jquery row
3条回答
Fickle 薄情
2楼-- · 2020-04-17 07:50

See this jsFiddle snippet:

http://jsfiddle.net/hU89p/

It returns the raw text inside all of the tds in the clicked row. Of course, if you need something more specific, continue with jQuery / JavaScript programming to get specific cells etc.

查看更多
Emotional °昔
3楼-- · 2020-04-17 07:53
$(document).ready(function () {      
 $('#YourTableid tr').click(function (event) {
       //do your logic here
 });
});
查看更多
戒情不戒烟
4楼-- · 2020-04-17 08:10

You mean it:

javascript:

​$('table tr td a').click(function(){
  alert($(this).text());
});​​​​​​​​​​​​​​​

html:

​<table>
  <tr>
    <td><a href="#">1</a></td>
  </tr>    
  <tr>
    <td><a href="#">2</a></td>
  </tr>    
  <tr>
    <td><a href="#">3</a></td>
  </tr>    
</table>

example​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

查看更多
登录 后发表回答