JQuery Do not allow Click on a Button that has a certain CSS Class

0

Hello everyone, I have an application with JQuery EasyUI, and I always call the click actions of the buttons with JQuery, as shown below:

$("#btnEditar").click(function(){
  ...
});

It happens that when clicking the button and it is disabled, it continues executing the Click action of JQuery.

I wonder if it would be possible to execute Button CLick only if it is without a particular css class, in my case .l-btn-disabled. I performed the test as below but it did not work:

$("#btnEditar").not(".l-btn-disabled").click(function(){
  ...
});

Thank you for your attention.

    
asked by anonymous 09.04.2015 / 14:30

1 answer

1

You can use it like this by using :not() :

$("#btnEditar:not('.l-btn-disabled')").click(function(){

But notice that you are using an ID in your selector, and ID must be unique. Uses classes on the buttons you want to select in ID times.

Example: link

    
09.04.2015 / 14:38