Home  >  Article  >  Web Front-end  >  jquery checkbox, judgment code for whether radio is selected_jquery

jquery checkbox, judgment code for whether radio is selected_jquery

WBOY
WBOYOriginal
2016-05-16 18:31:52888browse
1: Judge radio
Copy code The code is as follows:

var selected = $('input[name=selectid:checked]').val();//If not selected, val() = null
if(selected == null){
alert("Not selected ! ");
}else{
alert("Selected!");
}

2: Determine checkbox
Copy code The code is as follows:

var n = $("input:checked").length;
if (n==0){
alert("Not selected!");
}else{
alert("Selected!");
}
$("div"). text(n (n <= 1 ? " is" : " are") " checked!");
3: Select all, cancel all selection in checkbox array
$("#selAll").click( function(){
$("input[name='cbox[]']").attr("checked",$(this).attr("checked"));
});
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn