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'));
精彩评论