Check: the state of the $ (this) element in jQuery is enabled

Maybe I missed something and at the same time failed on google, but how would I say something like this:

... if ($(this:enabled)){ //some code } ... 

I know that you usually say something like $("#someID:enabled") , but how to use with $(this) ?

+5
source share
3 answers

You can use the is(selector) method:

 if ($(this).is(':enabled')) { // some code } 
+12
source

try the following:

 if($(this).is(':enabled')) 
0
source

jQuery has a filtering method that you can use to do this.

if( $(this).is(':enabled') ) { // do something here }

http://api.jquery.com/is/

0
source

Source: https://habr.com/ru/post/1210192/


All Articles