How to Disable My Toggle Button? This Is My Code
<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>

I want to disable my input button.

4

1 Answer

If you want to disable the button by default then

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

If you want to disable button on some action in 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
   });
});

Or, if you want to disabled by default on page load WITHOUT any action

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest