Menu ▼



Posted By :
avatarmrkraju
Total Views : 424

JQuery checkbox checked or not

For checking checkbox is checked or not using JQuery, we need to use the "prop" function. It will return the value "true" if check box is checked else returns "false".

Syntax: $("#chboption").prop("checked")

Example


Source Code

<html>
<head>
    <title></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script language="javascript">
        function IsCBSelected() {
            alert($("#chboption").prop("checked"));
        }       
    </script>
</head>
<body>
    <input type="checkbox" id="chboption" />
    <label for="chboption">
        Select this option</label>
    <br />
    <input type="button" onclick="IsCBSelected();" value="Test" />
</body>
</html>





comments powered by Disqus


Search dotnetlearners.com