我想显示在 span 元素中勾选的复选框数量。我如何实现这一目标?这是我的代码 -
<script>
$(document).ready(function(){
var n =$("[type='checkbox']:checked").length;
$("span").text(n);
});
</script>
</head>
<body>
<input type="checkbox">Red
<input type="checkbox">Green
<div id="result">
<p><span>0</span> are checked </p></div>
</body></html>