how to disable my toggle button? This is my code

<label>
<input type="checkbox" />
<span> </span>
<span></span>
</label>

I want to disable my input button.

4

1 Answer

If you want to disable the button by default then

<input type="checkbox" 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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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.

You Might Also Like