Jquery special effects (6)-check whether the check box is selected for question answering prompt and jquery Special Effects
Some time ago, I started thinking slowly. I learned from master for a while before I found that the gap was very big. It seems that I have to catch up with it ~ \ (Too many rows )/~ La la.
Recently, the company is working on a project and needs to give corresponding prompts Based on the options selected by the user. Let's take a look at the effect of the test program I wrote:
I. Implementation principle:
Step 1: Determine which check box is selected
Step 2: Give the corresponding prompt Based on the check box Selection
Ii. Let's look at the main program below:
<! DOCTYPE html>
We can also see from the above that I assume that this question is A single answer and the correct answer is A, then we will start to implement it with JQ ~~~
Iii. jQuery Program
$ (Function () {// assume the correct answer is A $ ("# button "). click (function () {if ($ ("input "). filter (": checked "). length = 0) {alert ("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 selected is correct! ")} Else {alert (" the answer you selected is incorrect! ")}})})
I have read a lot of programs on the Internet to determine whether the check box is selected. Most tests are useless. It is estimated that the jquery version updates have eliminated many programs. Who knows, later, $ ("# id") was used "). filter (": checked "). length = 0 it is acceptable to determine which option is selected and tested ~~~ If you have any other methods, please feel free to let me worship them ~~~