Skip to main content

How to Ignore First Div or Class or Element in Jquery

In Drupal or any JQuery function if you want to style or list or modify any div, class or css element ignoring the first element, you should use the 'gt(0)' or the greater than (zeroth) element like below:

Drupal.behaviors.<themename> = {
   attach: function (context, settings) {
     $('img:gt(0)').on('click', function(e) {

The above code will ignore the first image that is loaded in the DOM but apply the function to all other images. 

Change the class or div by using 

# or .

 $('#divname:gt(0)').on('click', function(e) {

 $('.classname:gt(0)').on('click', function(e) {

 


 

Technical