论坛首页 Web前端技术论坛

jquery获取一组radio被选中项的值

浏览 10774 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (9)
作者 正文
   发表时间:2008-01-15  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
     <meta http-equiv="Content-Type" c/>
     <script type="text/javascript" src="jquery.js">
    </script>
     <script type="text/javascript">
         $(function(){
             $('#form1').submit(function(){
                 var item = $('input[@name=items][@checked]').val();
                 alert(item);
                 return false;
             });
         });
     </script>
     <title>Get Radio value Document</title>
</head>
<body>
     <form id="form1">
         <input type="radio" name="items" id="item1" value="a"/>A
         <br/>
         <input type="radio" name="items" id="item2" value="b"/>B
         <br/>
         <input type="radio" name="items" id="item3" value="c"/>C
         <br/>
         <input type="radio" name="items" id="item4" value="d"/>D
         <br/>
         <input type="radio" name="items" id="item5" value="e"/>E
         <br/>
         <input type="radio" name="items" id="item6" value="f"/>F
         <br/>
         <input type="radio" name="items" id="item7" value="g"/>G
         <br/>
         <input type="radio" name="items" id="item8" value="h"/>H
         <br/>
         <input type="submit" id="btn1">
     </form>
</body>
</html>

论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics