Checkbox enabled count

1

This code counts how many checkbox was checked. How can I make it not include count checkbox disabled

<script type='text/javascript'>//<![CDATA[
window.onload=function(){
var contador = function() {
var n = $( "input:checked" ).length;
$("#checkcount").text( n + (n === 1 ? " é" : " são") + " selecionados" );
};
contador(); 
$( "input[type=checkbox]" ).on( "click", contador );
}//]]> 
</script>


<input type="checkbox" name="check1" disabled value="1">
<input type="checkbox" name="check1" disabled value="2">
<input type="checkbox" name="check1" value="3">
<input type="checkbox" name="check1" value="4">
<input type="checkbox" name="check1" value="5">    
<div id="checkcount"></div>
    
asked by anonymous 05.01.2016 / 00:22

1 answer

2

Instead

var n = $( "input:checked" ).length;

Put this:

var n = $( "input:enabled:checked" ).length;
    
05.01.2016 / 00:26