-->

28 April 2021

jQuery Checked Selector

  Asp.Net CS By Example       28 April 2021
jQuery Examining Checked Boxes and Radio Buttons

 In this post, One of the most powerful selectors is checked, which lets we select checked check boxes and selected radio buttons. We will put checked to work by counting the number of check boxes the user has checked. This example sets the text in a text field at the click of a button.

 $("input:checked") 

 Below code example puts for see above jQuery to Examining Checked Boxes and Radio Buttons by Checked Selector working.

jqscript.html
<html>
<head>
 <title>
   Counting checked checkboxes
 </title>
 <script src="http://code.jquery.com/jquery-latest.js"></script>
 <script type="text/javascript">
  function count( )
  {
    alert("You checked " +
    $("input:checked").length + " items.");
  }
 </script>
</head>
<body>
  <h1>Counting checked checkboxes</h1>
  <form>
    <input type="checkbox">
    Check 1
    </input>
    <input type="checkbox">
    Check 2
    </input>
    <input type="checkbox">
    Check 3
    </input>
    <input type="checkbox">
    Check 4
    </input>
    <br>
    <input type="button"
      value="Count"
      onclick="count( )"
    </input>
  </form>  
</body>
</html>


Output:

logoblog

Thanks for reading jQuery Checked Selector

Previous
« Prev Post

No comments:

Post a Comment

Please do not enter any spam link in the comment box.