Home >Web Front-end >JS Tutorial >Detailed explanation of Jquery getting the value selected by radio
This article mainly introduces the relevant knowledge of Jquery to obtain the radio selected value, which has a good reference value. Let's take a look with the editor below, I hope it can help everyone.
Without further ado, please take a look at the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.php.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.php.org/1999/xhtml"> <head> <title> new document </title> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="" /> <style type="text/css"></style> <script type="text/javascript" src="jquery-3.0.0.js"></script> </head> <body> <input type="radio" name="radio" value="1" />1<br/> <input type="radio" name="radio" value="2" />2<br/> <input type="radio" name="radio" value="3" />3<br/> <input type="radio" name="radio" value="4" /> <script type="text/javascript"> var a = $("input[name='radio']:checked").val(); alert("选中的radio的值是:" + a); </script> </body> </html>
Related recommendations:
##jQuery gets the radio button selected value and removes all radio selections Status Example Sharing
WeChat Mini Program Detailed Example of Radio Selected Style Switching
Example of How to Use JavaScript to Set Radio Selected
The above is the detailed content of Detailed explanation of Jquery getting the value selected by radio. For more information, please follow other related articles on the PHP Chinese website!