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?
http://jsfiddle.net/8gfYZ/11/ Check here..
Try
The following code works for me:
What worked for me was this:
But I like tomwadley's answer a lot more.
Nevertheless, the is(':disabled') code does also not work for me which should be the best version. Don't know, why it does not work. :-(
Try
$('#StartButton:disabled') ..
Then check if it's undefined.
Faced with the same issue when trying to check if a button is disabled. I've tried a variety of approaches, such as
btn.disabled
,.is(':disabled')
,.attr('disabled')
,.prop('disabled')
. But no one works for me.Some, for example
.disabled
or.is(':disabled')
returnedundefined
and other like.attr('disabled')
returned the wrong result -false
when the button was actually disabled.But only one technique works for me:
.is('[disabled]')
(with square brackets).So to determine if a button is disabled try this: