The example in this article tells you whether the jquery decision check box is selected for the answer hint effect code. Share to everyone for your reference. Specifically as follows:
The screenshot of the running effect is as follows:
The specific code is as follows:
First, the principle of implementation:
Step one: Determine which check box is selected by the user
Step two: Give the appropriate hints based on the check box selection
Second, the following to see the main program:
From the above also can see I assume this problem is a single choice, and the correct answer is a, then began to use JQ to achieve ~ ~ ~
Three, jquery program
$ (function () {
//Suppose the correct answer is a
$ ("#button"). Click (function () {
if ($ ("input"). Filter (": Checked"). length==0 {
alert ("Please select an option to submit");
} else if ($ ("#checkbox01"). Filter (": Checked"). length!=0&&$ ("#checkbox02"). Filter (": Checked"). length==0 &&$ ("#checkbox03"). Filter (": Checked"). length==0&&$ ("#checkbox04"). Filter (": Checked"). length==0 {
alert ("The answer you chose is correct!")
}else{
Alert ("The answer you chose is wrong!") ")
}
})
})
Before watching the online many judgments check box is selected, after testing is mostly useless, it is estimated that the jquery version of the update to eliminate a lot of programs caused it, who knows, and then use $ ("#id"). Filter (": Checked"). length== 0 It is OK to determine which option is checked and tested.
I hope this article will help you learn about the jquery program.