I was wondering if a callback would work with this simple two line jquery below? I'm pretty new so I just am looking to get bett开发者_如何学Pythoner :)
Thanks!
jQuery('.entry:first').addClass('firstEntry');
jQuery('.entry:first').removeClass('big');
jQuery('.entry:first').addClass('firstEntry').removeClass('big');
jQuery('.entry:first').addClass('firstEntry').removeClass('big');
jQuery supports chaining...
jQuery('.entry:first').addClass('firstEntry').removeClass('big');
Also, note there is a .toggleClass() method.
You could do this:
jQuery('.entry:first').addClass('firstEntry').removeClass('big');
var $entries = $(".entry");
$entries.first().addClass('firstEntry').removeClass('big');
or something a bit more readable...
var $entries = $(".entry");
$entries
.first()
.addClass('firstEntry')
.removeClass('big');
精彩评论