3
Answers

Enable button when checkbox clicked

Naseena P

Naseena P

11y
1.1k
1
How to enable button when checkbox clicked using jQuery
Answers (3)
0
Sanjeeb Lenka

Sanjeeb Lenka

NA 22.1k 1.3m 11y
hi,

try this html code:
add the reference of jQuery 1st

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="jquery-1.9.1.js" type="text/javascript"></script>
</head>
<body>
    <input id="Checkbox1" type="checkbox" />
    <input id="Button1" type="button" value="button" />
    <script type="text/javascript">
        $("#Checkbox1").click(function () {
            var checked_status = this.checked;
            if (checked_status == true) {
                $("#Button1").removeAttr("disabled");
            } else {
                $("#Button1").attr("disabled", "disabled");
            }
        });

    </script>
</body>
</html>

0
Sunny  Sharma

Sunny Sharma

NA 18.4k 1m 11y
try this:

$('#chkBox').click(function(){
$(this).is(':checked')?$('#button').removeAttr('disabled'):$('#button').attr('disabled','');
});
0
Navaz

Navaz

NA 96 32.4k 11y
//////// checkbox///// $("#CheckBox1").click(function () { $("#Button1").attr("disabled", !this.checked); });