:checked (selettore CSS e jQuery) riguarda gli elementi HTML di tipo <input> con attributo HTML type di valore radio o checkbox che abbiano il segno di spunta.
Sintassi
<!-- CSS -->
:checked {
/* codice */
}
<!-- JQUERY -->
$(":checked")
Esempi
<style>
:checked {
margin-left:20px;
height: 25px;
width: 25px;
}
</style>
<input type="checkbox" checked>1
<input type="checkbox">2
<input type="radio" name="aaa" checked>3
<input type="radio" name="aaa">4
1
2
3
4
<script>
jQuery(document).ready(function($) {
$(".esempio_jquery").click(function() {
if($(this).is(':checked')){
$(this).css({"margin-left":"20px","height":"25px", "width":"25px"});
} else {
$(this).css({"margin-left":"","height":"", "width":""});
}
});
$(".esempio_jquery:checked").css({"margin-left":"20px","height":"25px", "width":"25px"});
});
</script>
<input class="esempio_jquery" type="checkbox" checked>1
<input class="esempio_jquery" type="checkbox">2
<input class="esempio_jquery" type="radio" name="bbb" checked>3
<input class="esempio_jquery" type="radio" name="bbb">4
1
2
3
4
0 Comment