开发者

Jquery <tr> and id elements

Hi I am new to Jquery and wondered i开发者_运维知识库f 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


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).


To set the value:

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

To get the value:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜