2016-05-08 7 views
1
<label class="switch switch-yes-no" id="check_'+id+'" style="margin: 0;font-weight: bold;"> 
<input class="switch-input" type="checkbox" id="check_'+id+'" /> 
<span class="switch-label" data-on="Published" data-off="Hidden"> </span> 
<span class="switch-handle"></span> 
</label> 

入力ボタンを無効にしたいと思います。トグルボタンを無効にする方法は?これは私のコードです

+1

'$ WITHOUT負荷( '・入力を切り替える ')。(真、' 無効')小道具' – adeneo

+0

私はこれを試してみました何度も何度も動作していません。 –

+0

$( '。switch-input')。attr( 'disabled'、 'disabled') –

答えて

0

あなたは、デフォルトでは、ボタンを無効にしたい場合は、

<input class="switch-input" type="checkbox" id="check_'+id+'" disabled/> 

あなたがページにデフォルトで無効にしたい場合はjqueryの中にいくつかのアクション

$(function(){ 
    $('#SomeButton').on('click', function(){ 
     $('#your_input_id').attr('disabled' , 'disabled') //OR 
     $('#your_input_id').prop('disabled' , true) //true for disabled, false to enable 
    }); 
}); 

または、上のボタンを無効にしたい場合任意のアクション

$(function(){ 
     $('#your_input_id').attr('disabled' , 'disabled') //OR 
     $('#your_input_id').prop('disabled' , true) //true for disabled, false to enable 
}); 
+0

実際に私のコードが実行されたとき、ボタンはデフォルトでは無効になっていますが、いくつかのアクションで有効にしたいのですが –

+0

以前は.prop( 'disabled'、true)を試しましたが、動作していません。 –

+0

'.prop '、false) '既に無効になっているボタン/チェックボックスを有効にするには、' true'を使用して無効にします –

関連する問題