开发者

jquery .find issue

I'm moving down a table using the up/down arrow keys. I am manipulating the class开发者_开发技巧 of the <tr> tags to change the CSS class (highlighted/non-highlighted). I noticed when the screen loads and I click the arrow keys the first time tr_lst.attr('id') has a value but after the 2nd click it says it is undefined.

I think it has something to do with the manipulation of the CSS in the javascript code. Any ideas on how I can get this to print out a value after every keypress?

    var tr_lst = $('#' + ListBoxVal).find('tr[class="LUGridRowHighlight"]');
    console.log('tr_lst id: ' + tr_lst.attr('id'));


Because my comment helped you, I'm posting it as an answer:

Your selector in find could be written more simply as 'tr.LUGridRowHighlight'.


It probably is because you do not need to use find():

var tr_lst = $('#' + ListBoxVal + " tr.LUGridRowHighlight");
console.log('tr_lst id: ' + tr_lst.attr('id'));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜