jquery Determines whether the radio button radio is selected

Source: Internet
Author: User

This article mainly introduces the jquery to determine whether the radio button radio selected method, the example analysis of the loading page when the radio button ID and click button to get radio button ID two methods, very simple and practical, the need for friends can refer to the next

This example describes how jquery determines whether a radio button radio is selected. Share to everyone for your reference. Specific as follows:

The HTML code is as follows:

<input type= "Radio" id= "D1" name= "RA" value= "a" checked= "checked"/><input type= "Radio" id= "D2" Name= "RA" value = "B"/><input type= "Radio" id= "D3" Name= "Ra" value= "C"/>

1. Get ID when loading the page

$ ("input[type= ' Radio ')"). each (function () {  var id= $ (this). attr ("id");  if ($ ("#" +id). attr ("checked") = = "Checked") {   var fs=$ ("#" +id). Val ();  }); var S1 = $ (". Aa:checked"). Val (); . AA is Classvar s2 = $ ("Input[name= ' ra ']:checked"). Val ();

2. Get the ID when you click on the button

$ (function () {  $ ("input[type= ' Radio ')"). Click (function () {    var id= $ (this). attr ("id");    alert (ID);  });

It is hoped that this article will be helpful to everyone's jquery program design.

Originating From: http://www.jb51.net/article/65504.htm

jquery Determines whether the radio button radio is selected

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.