{"id":5523,"date":"2024-11-25T05:58:49","date_gmt":"2024-11-25T05:58:49","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=5523"},"modified":"2024-11-26T07:14:36","modified_gmt":"2024-11-26T07:14:36","slug":"how-to-know-which-radio-button-is-selected-via-jquery","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/","title":{"rendered":"How to Know Which Radio Button is Selected Via jQuery"},"content":{"rendered":"\n<p>Most websites and applications use HTML radio buttons to display choices for users to select. Often web developers need to determine which radio button is selected by users. This is required to find out and save user input. There are several ways to do this in jQuery library, which makes it very easy to work with HTML form elements. You can also do this using plain JavaScript, but it gets a little complicated. In this article, we will learn how to know which radio button is selected via jQuery. We will also learn how to do this using plain JavaScript.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#How_to_Know_Which_Radio_Button_is_Selected_Via_jQuery\" >How to Know Which Radio Button is Selected Via jQuery<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#Single_Radio_Button_Group\" >Single Radio Button Group<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#1_Using_checked_attribute_val_function\" >1. Using :checked attribute &amp; val() function<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#2_Using_name_attribute\" >2. Using name attribute<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#3_Using_type_attribute\" >3. Using type attribute<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#4_Using_class_name\" >4. Using class name<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#5_Determine_if_Any_Radio_Button_is_Checked\" >5. Determine if Any Radio Button is Checked<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#6_Using_filter_function\" >6. Using filter() function<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#7_Non_jQuery_Solution\" >7. Non jQuery Solution<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#Multiple_Radio_Button_Groups\" >Multiple Radio Button Groups<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#FAQs\" >FAQs<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Know_Which_Radio_Button_is_Selected_Via_jQuery\"><\/span>How to Know Which Radio Button is Selected Via jQuery<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We will look at how to determine which radio button is selected using jQuery. We will look at two use cases &#8211; where there is only one radio button group and where there are multiple radio button groups.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Single_Radio_Button_Group\"><\/span>Single Radio Button Group<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us say you have just one radio button group in an HTML form as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;form id='my_form'&gt;<br>   &lt;fieldset&gt;<br>    &lt;legend&gt;Choose radio button&lt;\/legend&gt;<br>    &lt;label&gt;&lt;input id=\"option1\" class=\"radio_button\" type=\"radio\" name=\"radio_name\" value=\"1\" \/&gt; 1&lt;\/label&gt; &lt;br \/&gt;<br>    &lt;label&gt;&lt;input id=\"option2\" class=\"radio_button\" type=\"radio\" name=\"radio_name\" value=\"2\" \/&gt; 2&lt;\/label&gt; &lt;br \/&gt;<br>    &lt;label&gt;&lt;input id=\"option3\" class=\"radio_button\" type=\"radio\" name=\"radio_name\" value=\"3\" \/&gt; 3&lt;\/label&gt; &lt;br \/&gt;<br>  &lt;\/fieldset&gt;<br>   <br>  &lt;\/form&gt;<\/pre>\n\n\n\n<p>There are several ways to determine which radio button is selected in jQuery. Let us look at some of the most common use cases.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_checked_attribute_val_function\"><\/span>1. Using :checked attribute &amp; val() function<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In jQuery, every radio button has an attribute <em>checked<\/em> that is set to true, if it is checked. Else it is set to false. jQuery also provides val() function for most HTML form elements, to directly return the selected value for inputs such as radio buttons and drop downs, and user input for textbox. We will use these checked attribute and val() function to get the checked value of radio button group. You can easily get the value of selected radio button using the following code.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('input[name=radio_name]:checked', '#my_form').val()<\/pre>\n\n\n\n<p>In the above code, we select the form input with name=radio_name, where attribute checked is set. We retrieve the value of selected radio button with name=radio_name in form with id=my_form using val() function.<\/p>\n\n\n\n<p>We call this code when the form changes, that is, when the change event is triggered for the form.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('#my_form input').on('change', function() {<br>  alert($('input[name=radio_name]:checked', '#my_form').val());<br>});<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_name_attribute\"><\/span>2. Using name attribute<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can shorten the above code by simply calling val() function directly on the radio button that has checked attribute set. Here is an example to illustrate it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('input[name=radio_name]:checked').val()<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Using_type_attribute\"><\/span>3. Using type attribute<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Alternatively, you can also use type attribute to pick the radio button that was selected. Here we are selecting the form input with type=radio, to select radio buttons. Among them, we filter that input where checked attribute is set.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$(\"#my_form input[type='radio']:checked\").val();<\/pre>\n\n\n\n<p>If there are multiple radio button groups and you want to find the selected option for specific radio button group then you can use type and name attribute together to find the right radio button group.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Using_class_name\"><\/span>4. Using class name<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can also select radio buttons using their class attribute. Here is an example to select all radio buttons with class=radio_button and then filter them further where checked attribute is set.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$(\"#my_form .radio_button:checked\").val()<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Determine_if_Any_Radio_Button_is_Checked\"><\/span>5. Determine if Any Radio Button is Checked<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you just want to determine if a specific radio button is selected or not, you can use is() function. It returns if a certain attribute is set for a given DOM element. In our case, we will check if the <em>checked<\/em> attribute is set or not. Here is the code to determine if radio button with id=option2 is selected or not.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$('#my_form input').on('change', function() {<br>  alert($(\"#option2\").is(':checked'));<br>});<\/pre>\n\n\n\n<p>When user selects any of the radio buttons, the above function is called. It will check if radio button #2 is selected. It returns true if that is the case, else it returns false. This is a good way to check if a specific radio button is selected.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6_Using_filter_function\"><\/span>6. Using filter() function<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>jQuery provides <a href=\"https:\/\/www.w3schools.com\/jquery\/traversing_filter.asp\" target=\"_blank\" rel=\"noreferrer noopener\">filter()<\/a> function that returns one or more elements that match certain selection criteria. Here is an example, where we first select all radio buttons with name=radio_button and then call filter() function with criteria &#8216;:checked&#8217; to select the checked radio button.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$(\"input[name=radio_name]\").filter(\":checked\").val()<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7_Non_jQuery_Solution\"><\/span>7. Non jQuery Solution<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you do not use jQuery, you can also go for the following plain JavaScript code to determine the selected radio button.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">for (let el of document.querySelectorAll('#my_form input'))<br>el.addEventListener('change', () =&gt;<br>   alert(document.querySelector('input[name=radio_name]:checked', '#my_form').value) <br>);<\/pre>\n\n\n\n<p>In the above code, we loop through all radio buttons in our HTML form. For each radio button, we add an event listener that is triggered on &#8216;change&#8217; event. Whenever any of the radio button is checked, its event handler is called. This event handler will basically return the value attribute of selected radio button.<\/p>\n\n\n\n<p>It is more complicated than plain jQuery code but useful if you are unable to use jQuery in your code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Multiple_Radio_Button_Groups\"><\/span>Multiple Radio Button Groups<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes, you may have multiple radio button groups on a single HTML form. Let us say you have the following HTML radio button groups.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;form id='my_form'&gt;<br>   &lt;fieldset&gt;<br>    &lt;legend&gt;Choose radioName&lt;\/legend&gt;<br>    &lt;label&gt;&lt;input id=\"option1\" class=\"radio_button\" type=\"radio\" name=\"radio_name\" value=\"1\" \/&gt; 1&lt;\/label&gt; &lt;br \/&gt;<br>    &lt;label&gt;&lt;input id=\"option2\" class=\"radio_button\" type=\"radio\" name=\"radio_name\" value=\"2\" \/&gt; 2&lt;\/label&gt; &lt;br \/&gt;<br>    &lt;label&gt;&lt;input id=\"option3\" class=\"radio_button\" type=\"radio\" name=\"radio_name\" value=\"3\" \/&gt; 3&lt;\/label&gt; &lt;br \/&gt;<br>  &lt;\/fieldset&gt;<br>  <br>  &lt;fieldset&gt;<br>    &lt;legend&gt;Choose radioName2&lt;\/legend&gt;<br>    &lt;label&gt;&lt;input id=\"option12\" class=\"radio_button2\" type=\"radio\" name=\"radio_name2\" value=\"a\" \/&gt; a&lt;\/label&gt; &lt;br \/&gt;<br>    &lt;label&gt;&lt;input id=\"option22\" class=\"radio_button2\" type=\"radio\" name=\"radio_name2\" value=\"b\" \/&gt; b&lt;\/label&gt; &lt;br \/&gt;<br>    &lt;label&gt;&lt;input id=\"option32\" class=\"radio_button2\" type=\"radio\" name=\"radio_name2\" value=\"c\" \/&gt; c&lt;\/label&gt; &lt;br \/&gt;<br>  &lt;\/fieldset&gt;<br>   <br>  &lt;\/form&gt;<\/pre>\n\n\n\n<p>There are several ways to retrieve the values of each radio button group. In each case, you will need to get them separately. Here is an example to get the checked radio button values, using <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var myRadio1 = $('input[name=radio_name]').filter(':checked').val();<br>var myRadio2 = $('input[name=radio_name2]').filter(':checked').val();<br>console.log(myRadio1, myRadio2);<\/pre>\n\n\n\n<p>You can also use class attributes to select the radio button groups, as long as they are different for each radio button group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var myRadio1 = $('.radio_button').filter(':checked').val();<br>var myRadio2 = $('.radio_button2').filter(':checked').val();<br>console.log(myRadio1, myRadio2);<\/pre>\n\n\n\n<p>This is a more efficient solution that looping through all radio buttons, or radio button groups.<\/p>\n\n\n\n<p>Please remember to include jQuery library for the above code to work. Here is a sample complete code for your reference.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;html&gt;<br>&lt;head&gt;<br>&lt;script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.7.1\/jquery.min.js\"&gt;&lt;\/script&gt;<br>&lt;\/head&gt;<br>&lt;body&gt;<br>&lt;form id='my_form'&gt;<br>   &lt;fieldset&gt;<br>    &lt;legend&gt;Choose radioName&lt;\/legend&gt;<br>    &lt;label&gt;&lt;input id=\"option1\" class=\"radio_button\" type=\"radio\" name=\"radio_name\" value=\"1\" \/&gt; 1&lt;\/label&gt; &lt;br \/&gt;<br>    &lt;label&gt;&lt;input id=\"option2\" class=\"radio_button\" type=\"radio\" name=\"radio_name\" value=\"2\" \/&gt; 2&lt;\/label&gt; &lt;br \/&gt;<br>    &lt;label&gt;&lt;input id=\"option3\" class=\"radio_button\" type=\"radio\" name=\"radio_name\" value=\"3\" \/&gt; 3&lt;\/label&gt; &lt;br \/&gt;<br>  &lt;\/fieldset&gt;<br>   <br>  &lt;\/form&gt;<br>&lt;script type='text\/javascript'&gt;<br><br>$('#my_form fieldset label input').on('change', function() {<br>  alert($('input[name=radio_name]:checked').val());<br>});<br><br>&lt;\/script&gt;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt several different ways to determine which radio button is checked, using jQuery. The key is to pick radio buttons using any of its attributes such as type, id, class, name, etc. and filter them further using checked attribute. We have also learnt how to find checked radio button using plain JavaScript. We also saw how to determine checked radio button, in case there are multiple radio button groups. You can use any of these solutions according to your requirement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"FAQs\"><\/span>FAQs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>1. Do I need to always use jQuery to get selected radio button?<\/strong><\/p>\n\n\n\n<p>No. You can also determine the checked radio button using plain JavaScript or other third-party JS libraries. Using plain JavaScript is a little complicated, whereas jQuery provides many intuitive and easy to use functions for this purpose.<\/p>\n\n\n\n<p><strong>2. How to get selected radio button in case of multiple radio button groups?<\/strong><\/p>\n\n\n\n<p>You will need to separately select the checked radio button for each radio button group, using any of the above methods.<\/p>\n\n\n\n<p>Also read:<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/tech-blog\/how-javascript-closures-work\/\">How JavaScript Closures Work<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-whether-string-contains-substring-in-javascript\/\">How to Check Whether String Contains Substring in JavaScript<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-property-from-javascript-object\/\">How to Remove Property from JavaScript Object<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most websites and applications use HTML radio buttons to display choices for users to select. Often web developers need to determine which radio button is selected by users. This is required to find out and save user input. There are several ways to do this in jQuery library, which makes it very easy to work [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5556,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[295],"tags":[336],"class_list":["post-5523","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-radio-button"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Know Which Radio Button is Selected Via jQuery - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Often web developers need to know which radio button is selected in jQuery. Here are the different ways to determine checked radio button.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Know Which Radio Button is Selected Via jQuery - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Often web developers need to know which radio button is selected in jQuery. Here are the different ways to determine checked radio button.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-25T05:58:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-26T07:14:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/11\/check-radio-button-is-selected.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"308\" \/>\n\t<meta property=\"og:image:height\" content=\"204\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Know Which Radio Button is Selected Via jQuery\",\"datePublished\":\"2024-11-25T05:58:49+00:00\",\"dateModified\":\"2024-11-26T07:14:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/\"},\"wordCount\":1079,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/check-radio-button-is-selected.jpg?fit=308%2C204&ssl=1\",\"keywords\":[\"radio button\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/\",\"name\":\"How to Know Which Radio Button is Selected Via jQuery - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/check-radio-button-is-selected.jpg?fit=308%2C204&ssl=1\",\"datePublished\":\"2024-11-25T05:58:49+00:00\",\"dateModified\":\"2024-11-26T07:14:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Often web developers need to know which radio button is selected in jQuery. Here are the different ways to determine checked radio button.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/check-radio-button-is-selected.jpg?fit=308%2C204&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/check-radio-button-is-selected.jpg?fit=308%2C204&ssl=1\",\"width\":308,\"height\":204,\"caption\":\"check if radio button is selected\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-know-which-radio-button-is-selected-via-jquery\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Know Which Radio Button is Selected Via jQuery\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Know Which Radio Button is Selected Via jQuery - Ubiq BI","description":"Often web developers need to know which radio button is selected in jQuery. Here are the different ways to determine checked radio button.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/","og_locale":"en_US","og_type":"article","og_title":"How to Know Which Radio Button is Selected Via jQuery - Ubiq BI","og_description":"Often web developers need to know which radio button is selected in jQuery. Here are the different ways to determine checked radio button.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2024-11-25T05:58:49+00:00","article_modified_time":"2024-11-26T07:14:36+00:00","og_image":[{"width":308,"height":204,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/11\/check-radio-button-is-selected.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Know Which Radio Button is Selected Via jQuery","datePublished":"2024-11-25T05:58:49+00:00","dateModified":"2024-11-26T07:14:36+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/"},"wordCount":1079,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/11\/check-radio-button-is-selected.jpg?fit=308%2C204&ssl=1","keywords":["radio button"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/","name":"How to Know Which Radio Button is Selected Via jQuery - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/11\/check-radio-button-is-selected.jpg?fit=308%2C204&ssl=1","datePublished":"2024-11-25T05:58:49+00:00","dateModified":"2024-11-26T07:14:36+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Often web developers need to know which radio button is selected in jQuery. Here are the different ways to determine checked radio button.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/11\/check-radio-button-is-selected.jpg?fit=308%2C204&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/11\/check-radio-button-is-selected.jpg?fit=308%2C204&ssl=1","width":308,"height":204,"caption":"check if radio button is selected"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-know-which-radio-button-is-selected-via-jquery\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Know Which Radio Button is Selected Via jQuery"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2024\/11\/check-radio-button-is-selected.jpg?fit=308%2C204&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-1r5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/5523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=5523"}],"version-history":[{"count":41,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/5523\/revisions"}],"predecessor-version":[{"id":5573,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/5523\/revisions\/5573"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/5556"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=5523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=5523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=5523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}