:checked Seçicisi

checked selector
Açıklama : Seçilmiş olan veya "checked" olan tüm elemanları seçer.

jQuery( ":checked" ) Eklendiği Versiyon 1.0

:checked seçicisi checkboxlar, radio buttonlar ve select elemanlarının opsiyonları için kullanılır.

Bir select elemanının sadece seçili olan opsiyonlarını okumak için :selected seçicisi kullanın.



Örnekler:

Kaç tane input elemanın seçili olduğunu hesapla.

<style> div { color: red; } </style>
<form>
   <p>
      <input type="checkbox" name="newsletter" value="Hourly" checked="checked">
      <input type="checkbox" name="newsletter" value="Daily">
      <input type="checkbox" name="newsletter" value="Weekly">
      <input type="checkbox" name="newsletter" value="Monthly" checked>
      <input type="checkbox" name="newsletter" value="Yearly">
   </p>
</form>
<div></div>
<script>
   var countChecked = function() {
      var n = $( "input:checked" ).length;
      $( "div" ).text( n + (n === 1 ? " is" : " are") + " checked!" );
   };
   countChecked();
   
   $( "input[type=checkbox]" ).on( "click", countChecked );
</script>


Seçili olan radio butonu belirt.

<style> #test2 input, #test2 label { line-height: 1.5em; } </style>
<form>
   <div>
      <input type="radio" name="fruit" value="orange" id="orange">
      <label for="orange">orange</label>
   </div>
   <div>
      <input type="radio" name="fruit" value="apple" id="apple">
      <label for="apple">apple</label>
   </div>
   <div>
      <input type="radio" name="fruit" value="banana" id="banana">
      <label for="banana">banana</label>
   </div>
   <div id="log"></div>
</form>
<script>
$( "#test2 input" ).on( "click", function() {
   $( "#test2 #log" ).html( $( "#test2 input:checked" ).val() + " is checked!" );
});
</script>

.

.