Jquery special effects (6)-check whether the check box is selected for question answering prompt and jquery Special Effects

Source: Internet
Author: User

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 ~~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.