How to do something different with first element in each loop?

Within an each() loop, is it possible to do something with the first element in particular, not the next ones? Something like this:

$( '.selector').each(function(){
  // if first element found, do something


You could determine if it is the first element by checking the index.

$('.selector').each(function(i, el) {
  if (i === 0) {
   // first element.. use $(this)

Alternatively, you could also just access the first element outside of the loop using the .first() method:


The :first selector would also work: