GeekyOwl
GeekyOwl

Reputation: 79

In jQuery is there any method similar to on('click' for checkbox enabled event?

I have accending and descending sort icons for sorting purposes. On the initial loading, sorting is in an enabled condition I am in need of a solution similar to below:

$('.pgggo-container-ajax-sorting').on('click', '.pgggocheckboxdecendinp', function(event) {

say when the descend icon is clicked this function should run. But the above method is not working for a checkbox. Please help

Upvotes: 1

Views: 53

Answers (1)

Nikhil Gyan
Nikhil Gyan

Reputation: 682

You can try this:

$('.pgggo-container-ajax-sorting').on('click', '.pgggocheckboxdecendinp', function(event) {
  if($(this).is(':checked')) {
    //  code for checked condition
  }
  else {
    //  code for unchecked condition
  }
});

This will work with checkbox.

Upvotes: 1

Related Questions