tags:

views:

31

answers:

2

Hi I am new to Jquery and wondered if I can give a an ID and if so how can I then get the value back . The best I have come up with so for is

  rid = $('tr').attr('id').val() 

but no luck ......

thanks

+3  A: 

No need for the .val(), just use this:

var rid = $('tr').attr('id'); 

.attr('attributeName') returns a string (in most cases) of the attribute, .val() is for getting the value from input type elements (<input>, <select>, <textarea>, etc).

Nick Craver
+1  A: 

To set the value:

$('tr').attr('id', 'someValue');

To get the value:

var id = $('tr').attr('id');
Darin Dimitrov