How to Enable/Disable Input element in JQuery

To disable input elements (checkbox, radio button, text box, button etc) in jquery, you need to set disabled attribute.

// check box
$("#check_box_id").attr("disabled", "disabled");
// radio button
$("#radio_btn_id").attr("disabled", "disabled");
// Text box
$("#text_box_id").attr("disabled", "disabled");
// button
$("#btn_id").attr("disabled", "disabled");

To Enable the input elements (checkbox, radio button, text box, button etc) , we need to remove disabled attribute. This can be done in the following way.

// check box
$("#check_box_id").removeAttr("disabled");
// radio button
$("#radio_btn_id").removeAttr("disabled");
// Text box
$("#text_box_id").removeAttr("disabled");
// button
$("#btn_id").removeAttr("disabled");

Related Post

jQuery – A lightweight JavaScript Library
Differences between Vector and ArrayList
Differences between ArrayList and LinkedList
Implement a stack?
Iterating over Map

Comments

Leave a Reply