jquery decision check box is checked for answer tip special effects _jquery

Source: Internet
Author: User

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:

<! DOCTYPE html>
 
 

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.

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.