Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Mobile how to check if button is disabled?

I disable the button like this on my jQuery Mobile webpage:

$(document).ready(function() {     $("#deliveryNext").button();     $("#deliveryNext").button('disable'); }); 

and i can enable it with

$("#deliveryNext").button('enable'); 

But how do i check if the button is disabled or enabled?

This command gives "undefined":

$("#deliveryNext").attr('disabled') 

Some ideas?

Edit: i find out that $("#deliveryNext").button('disable') only seams to change the style on the button, the clicking works fine after so i need to disable the button some how also.. i tried .attr('disabled', 'disabled') but when i then test .attr('disabled') i get undefined...

Edit2: more about my "real" problem at How to disable a link button in jQuery Mobile?

like image 835
RickardP Avatar asked Jun 22 '11 08:06

RickardP


People also ask

How do I check if a button is enabled or disabled in jQuery?

Checking if the button is disabled or enabled with jQuery removeAttr('disabled'); }; const checkButton = (e) => { const isDisabled = $('#my-button'). prop('disabled'); if( isDisabled ){ alert("Is disabled!"); } else{ alert("Is enabled"); } }; $(document).

How do you check if a button is enabled or not?

ImageButton myButton = (ImageButton) findViewById(R. id. epic_button); if (myButton. isEnabled()){ //then the button is enabled. }

How would you check if a button is disabled on a page?

Use the disabled property to check if an element is disabled, e.g. if (element. disabled) {} . The disabled property returns true when the element is disabled, otherwise false is returned. Here is the HTML for the examples in this article.


1 Answers

try :is selector

$("#deliveryNext").is(":disabled") 
like image 86
Vivek Avatar answered Sep 22 '22 04:09

Vivek