Can this be written more elegantly?

I was wondering if the callback would work with this simple two-line jquery below? I'm pretty new, so I just want to get better :)

Thanks!

jQuery('.entry:first').addClass('firstEntry'); jQuery('.entry:first').removeClass('big'); 
+4
source share
5 answers
 jQuery('.entry:first').addClass('firstEntry').removeClass('big'); 
+6
source
 jQuery('.entry:first').addClass('firstEntry').removeClass('big'); 
+2
source

jQuery supports chaining ...

 jQuery('.entry:first').addClass('firstEntry').removeClass('big'); 

Also pay attention to the .toggleClass () method.

+2
source

You can do it:

 jQuery('.entry:first').addClass('firstEntry').removeClass('big'); 
+1
source
 var $entries = $(".entry"); $entries.first().addClass('firstEntry').removeClass('big'); 

or something more readable ...

 var $entries = $(".entry"); $entries .first() .addClass('firstEntry') .removeClass('big'); 
0
source

All Articles