Search code examples
jqueryonclickspry

spryassets click event in jQuery


I have the following in my page,

This is a spryasset. This has 3 tabs.enter image description here

When I click "reviews" it shows reviews, if "more" then it shows more.

My question is,

How to listen to this "CLICK" event on a spryasset tab in jQuery?


Solution

  • Assuming that spryasset produces li for each tab you could do this:

    $('#tabs li:eq(2)').on('click', function() {
      // your code here
    });
    

    Update:

    The :eq(2) will return the 3rd (starting from 0) list element that is a child of some element with id=tabs. For more information on the :eq selector check out the jquery docs http://api.jquery.com/eq-selector/