0

我试图禁用我的 jquery 移动应用程序上的提交按钮。我已经尝试了好几天才能让它工作。这些按钮不会启用或禁用。这是我尝试输入的众多脚本之一

document.addEventListener("deviceready", onDeviceReady, false);


function onDeviceReady() {
    checkConnection();
}

function checkConnection() {
    var networkState = navigator.network.connection.type;

    var states = {};
    states[Connection.UNKNOWN]  = 'Unknown connection';
    states[Connection.ETHERNET] = 'Ethernet connection';
    states[Connection.WIFI]     = 'WiFi connection';
    states[Connection.CELL_2G]  = 'Cell 2G connection';
    states[Connection.CELL_3G]  = 'Cell 3G connection';
    states[Connection.CELL_4G]  = 'Cell 4G connection';
    states[Connection.NONE]     = 'No network connection';


        if(networkState==Connection.UNKNOWN || networkState==Connection.NONE) {
            $('[type="submit"]').button('disable');
            $('[type="submit"]').button('refresh');

        } else {
            $('[type="submit"]').button('enable');
            $('[type="submit"]').button('refresh');


        }

`

4

2 回答 2

1

不应该是这样的吗:

if(networkState==states.Connection.UNKNOWN || networkState==states.Connection.NONE) {
   //........... your code stuff..............//
}
于 2013-03-07T09:36:24.830 回答
0

试着打电话

mybutton.disabled = true
于 2013-03-07T09:38:42.153 回答