• No categories

Check Uncheck checkbox in jquery

Hello Everybody, here i am going to show, how you can check or uncheck a checkbox with jquery. you can download latest version of jquery from here [download jquery]. In this code i used two functions of jquery for adding and removing a attribute(disabled).
Jquery function attr(‘name’,’value’) is used to add an attribute to an html element. Function removeAttr(‘name’) is used to remove a attribute of html element by using jquery.
Insert a checkbox using following code :
<input type=”checkbox” id=”mycbox”/>Click on buttons to check/uncheck.

Insert buttons using the following code :
<input type=”button” value=”Check” onclick=’$(“#mycbox”).attr(“checked”,”checked”)’/>
<input type=”button” value=”Uncheck” onclick=’$(“#mycbox”).removeAttr(“checked”)’/>

About the Author:

Comments are closed.