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

jquery checkbox, judgment code for whether radio is selected_jquery

WBOY
Release: 2016-05-16 18:31:52
Original
950 people have browsed it
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"));
});
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template