Thursday, August 21, 2014

When using jQuery, let its API do the heavy lifting

Instead of this:

var particles = $('.particle');
$('li').each(function() {
    if (!$(this).is(particles))
        $(this).css('color','red');
});    



Do this:
var particles = $('.particle');
$('li').not(particles).css('color','red')

No comments:

Post a Comment