simulate a click in the NEXT row...
simulate a click in the NEXT row...
Hello,
I'm using this to make blue the clicked row
function highlight() {
if ( $(this).hasClass('active') ) { }
else {
table1.$('tr.active').removeClass('active');
$(this).addClass('active');
myDatas = table1.row(this).data();
// and do things with myDatas
}
$("#table1 tbody").on("click", "tr", highlight);
and a button triggers this in order to highlight the row immediately after the one being highlighted now :
var index_of_selected_line_in_table1 = table1.row('tr.active').index();
table1.$('tr.active').removeClass('active'); // I want to
$(table1.row(index_of_selected_line_in_table1+1).node()).addClass('active');
It works perfectly but in fact, I would like to simulate a click on the next row instead of only adding 'active' class on it because I make some useful actions in the highlight() function that I would like to run. The problem is that I cannot call "highlight()" simply after addind 'active' class (I tried and the 'myDatas' variable is 'undefined').
So how can I do to simulate a user click on the line immediately after the one which has 'active' class ?
Thank you very much for your help !
T.
Answers
With jQuery you can just call the
click()
function (jQuery docs) if you have the node already - which it appears you do:Allan
Wonderful :-) that's easy :-) Thank you VERY much !!