Jquery Filtering

Jquery first()

The first() method returns first element of selected element.

$(document).ready(function(){
 $('span').first().css({
  fontSize: '20px',
  color: 'black'
 });
});


Jquery last()

The last() method returns last element of selected element.

$(document).ready(function(){
 $('span').last().css({
  fontSize: '20px',
  color: 'black'
 });
});


Jquery eq()

The eq() method returns element with a specific number of selected elements.

$(document).ready(function(){
 $('span').eq(3).css({
  fontSize: '20px',
  color: 'black'
 });
});


Jquery filter()

The filter() method lets you specify a criteria and only those element which meets criteria are returned.

$(document).ready(function(){
 $('span').filter('.test').css({
  fontSize: '20px',
  color: 'black'
 });
});


Jquery not()

The not() method returns all elements that do not match criteria.

$(document).ready(function(){
 $('span').not('.test').css({
  fontSize: '20px',
  color: 'black'
 });
});

Share this

Related Posts