Most people probably think of this method when verifying:
function chk () //Verify whether it is selected return true, if not return false
{
var falg = 0;
$("input[name=cbname]:checkbox").each(function( ){
if($(this).attr("checked")) // Here you can use if($("#cr").is(":checked"))
{
falg =1; // You can add return false here to exit the loop
}
})
if(falg >0)
return true;
else
return false;
}
This method is really good, but I think the following code is simpler and more efficient:
if($("input[name=cbname]:checkbox").length==0 ) // None of the options are selected
Selected according to needs