I used to write this:
$('#MyDiv .TheClass').eq(TheIndex).removeClass('ClassA');
$('#MyDiv .TheClass').eq(TheIndex).removeClass('ClassB');
$('#MyDiv .TheClass').eq(TheIndex).addClass('ClassC');
$('#MyDiv .TheClass').eq(TheIndex).children().each(function () {
//do something here
});
and now I’m writing this:
$('#MyDiv .TheClass').eq(TheIndex)
.removeClass('ClassA ClassB')
.addClass('ClassC')
.children().each(function () {
// do something here
});
Is the latter going to run faster than the former? Just curious.
One thing’s for sure, this codes FINDS the element each line:
In chaining, if finding the element is just once, it is faster then: