JQueryMobile-按钮 [英] JQueryMobile - Button

查看:95
本文介绍了JQueryMobile-按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在使用jquery mobile的编码中禁用按钮?

How to disable the button in coding using jquery mobile?

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

[注意:我想在编码中而不是在设计时禁用按钮]

[Note : I want to disable the button in the coding, not in the design time]

推荐答案

实时示例: http://jsfiddle.净/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);

更新:

链接按钮示例:

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>

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

样式类似于按钮的链接具有与true相同的视觉选项 下面是基于表单的按钮,但有一些重要的区别. 基于链接的按钮不是按钮插件的一部分,只能使用 基本的buttonMarkup插件来生成按钮样式,因此 不支持表单按钮方法(启用,禁用,刷新). 如果您需要禁用基于链接的按钮(或任何元素),则可以 可以将禁用类自己应用于ui-disabled JavaScript可以达到相同的效果.

Links styled like buttons have all the same visual options as true form-based buttons below, but there are a few important differences. Link-based buttons aren't part of the button plugin and only just use the underlying buttonMarkup plugin to generate the button styles so the form button methods (enable, disable, refresh) aren't supported. If you need to disable a link-based button (or any element), it's possible to apply the disabled class ui-disabled yourself with JavaScript to achieve the same effect.

这篇关于JQueryMobile-按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆