Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
48
rated 0 times [  50] [ 2]  / answers: 1 / hits: 19957  / 11 Years ago, mon, march 4, 2013, 12:00:00

I have the following table:



<table id=messages border=1>
<tbody>
<tr>
<th>Name</th>
<th>Text</th>
<th>Subject</th>
</tr>
<tr value=1>
//data
</tr>
<tr value=2>
//data
</tr>
</tbody>
</table>


I need some jquery that will return the val attribute of the clicked tr. I already have jquery that will return an array of all teh inclosed td within the tr but i still need the value saved to a variable. Any help?


More From » jquery

 Answers
3

It's not advisable to add value attributes to non-input elements, because that makes no sense to the browser. Change <tr value=1> to <tr data-value=1> and access it using $tr.data('value') (where $tr is a jQuery object for one unique table row).



http://api.jquery.com/data/


[#79842] Sunday, March 3, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elians

Total Points: 417
Total Questions: 87
Total Answers: 101

Location: Barbados
Member since Sun, Nov 27, 2022
2 Years ago
;