All TalkersCode Topics

Follow TalkersCode On Social Media - A Social Media Network for developers Join Now ➔

jQuery Get Radio Button Value

Last Updated : Mar 11, 2024

jQuery Get Radio Button Value

In this article we will show you the solution of jQuery get radio button value, here we needs to use click() and val() methods for achieve the result.

The click() method triggers the click event, or attaches a function to run when a click event occurs then val() method will returns value of specified element in html which is purposely used for collect checked radio button value as result on alertbox.

Step By Step Guide On jQuery Get Radio Button Value :-

Here we defined html block with h3 tag for displays heading, four radio buttons with different options and button ‘Submit’.

In script block we defined ready() method which is automatically starts loading code of within this function when this program opened on browser and within that we waiting for click event occurrence then it will loads all radio buttons checked state for finds out which is checked then we appends val() with that then it returns checked radio button value on alertbox.

<!DOCTYPE html>
        <title>Value of Radio Button</title>
        <script src=""></script>
            $(document).ready(function (){
            <h3>Select Anyone Option</h3>
                <input type="radio" value="Ducatti">Ducatti
                <input type="radio" value="RX">RX
                <input type="radio" value="KTM">KTM
                <input type="radio" value="Pulser">Pulser
  1. <!DOCTYPE html> tag which is instruct the web browser about what version of HTML file written in and it’s not have any ending tag.
  2. The<html> tag is used to indicate the beginning of HTML document.
  3. As above shown <head> tag is contain information about webpage and external file links are declared here. <title> tag is used for set the webpage title.
  4. Here we imported open source jquery library support file which is needed for coding using jquery in program.
  5. Both <head> and <title> tags having their pair end tag, so we need to close the ending tags respectively. If you’re not closed anyone of ending tag properly that is also affect the webpage result.
  6. <body> tag is beginning of main coding part because it contain coding of entire website blocks and elements described here.
  7. In script we defined ready() method within that we appending click() method with ‘button’ for generate click event when user clicks on ‘Click Here’ button.
  8. Then we collecting checked radio button by ‘$('input[type="radio"]:checked')’ which means it covers all radio button then it checks which one is in checked then it returns boolean value and we needs to append that with val().
  9. With the help of val() only returns value of checked radio button and using alert method we displaying final result on alert box at webpage.
  10. In html block we defined h3 tag for showing heading and button, four input elements with radio button type ‘Ducatti, RX, KTM, Pulser’.
  11. Both </body>,</html> tags closed respectively. </body> tag indicates the end of body, Then </html> tag indicates the end of HTML document.

Conclusion :-

In conclusion now we are able to know how to get checked radio button value in jquery.

Before execution of program we needs to confirm internet connection because then only that jquery file will supports defined jquery codes without error.

When we executes program on browser we can see heading ‘Select Anyone Option’, button ‘Submit’ and radio buttons ‘Ducatti, RX, KTM, Pulser’.

There user needs to click on anyone radio button then clicks on ‘Submit’ button result of selected radio button value displayed on alert box like ‘Ducatti’.

I hope this article on jQuery get radio button value helps you and the steps and method mentioned above are easy to follow and implement.