Value[Note: I want ...">

JQueryMobile - Button

How to disable a button in encoding using jquery mobile?

<div data-role="button" id="val">Value</div>

[Note: I want to disable the button in encoding, not during development]

+3
source share
3 answers

Live Example: http://jsfiddle.net/LHG4L/5/

HTML:

<div data-role="page">
    <div data-role="content">
        <input type="button" id="theButton" name="theButton" value="The Button">
    </div>
</div>

JS:

$('#theButton').attr('disabled',true);

UPDATE:

Example link button:

Js

var clicked = false;

$('#myButton').click(function() {
    if(clicked === false) {
        $(this).addClass('ui-disabled');
        clicked = true;
        alert('Button is now disabled');
    } 
});

$('#enableButton').click(function() {
    $('#myButton').removeClass('ui-disabled');
    clicked = false; 
});

HTML

<div data-role="page" id="home">
    <div data-role="content">

        <a href="#" data-role="button" id="myButton">Click button</a>
        <a href="#" data-role="button" id="enableButton">Enable button</a>

    </div>
</div>

NOTE: - http://jquerymobile.com/demos/1.0rc2/docs/buttons/buttons-types.html

, , , , . buttonMarkup , (, , ) . ( ), ui-disabled JavaScript .

+6

, jquery, jquerymobile:

$('#theButton').attr('disabled', true);
if ($('#theButton').button) $('#theButton').button('disable')
+1

You can disable the button using the attribute class="ui-disabled"as follows:

<a href="index.html" data-role="button" class="ui-disabled">Link button</a> 
+1
source

All Articles