Many friends now like jquery, so many table judgments are based on jquery, but the implementation method is different from the javascript native code. For more information about checkbox judgments, see.
The Code is as follows:
// Check whether the selected return true and no return false are selected.
Function mycheckbox (){
Var falg = 0;
$ ("Input [name = 'soft [] ']: checkbox"). each (function (){
If ($ (this). attr ("checked ")){
Falg + = 1;
}
})
If (falg> 0)
Return true;
Else
Return false;
}
This is a good method.
The following function is a supplement to the above:
The Code is as follows:
This is the writing method. Jq1.42.
Next, we recommend that you process the logic.
Function mycheckbox (){
Var falg = 0;
$ ("Input [name = 'soft [] ']: checkbox"). each (function (){
If ($ (this). attr ("checked ")){
Falg = 1;
Return false;
}
})
If (falg> 0)
Return true;
Else
Return false;
}
Below is a simple judgment
Jquery core judgment statement
If ($ ('input: checkbox'). attr ("checked") = true)
Everyone knows that in html, if a check box is selected as checked = "checked ".
However, if jquery alert ($ ("# id"). attr ("checked") is used, you will be prompted to be true instead of checked.
So many friends judge if ($ ("# id "). attr ("checked") = "true") This is incorrect. It should actually be if ($ ("# id "). attr ("checked") = true)
The example contains several functions.
Code
The Code is as follows:
New Document