Home  >  Article  >  Web Front-end  >  Detailed explanation of Jquery method to obtain radio selected value

Detailed explanation of Jquery method to obtain radio selected value

php中世界最好的语言
php中世界最好的语言Original
2018-04-23 16:53:281879browse

This time I will bring you Jquerydetailed explanation of the method of obtaining the radio selected value. What are the precautions for Jquery to obtain the radio selected value. The following is a practical case, let's take a look.

Without further ado, please take a look at the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.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>

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to implement addition, deletion and modification of select option in jQuery

$(function() {} in jQuery )Use Cases

The above is the detailed content of Detailed explanation of Jquery method to obtain radio selected value. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn