<input type="radio" class="is" name="why3185"   value="0">0</p><input type="radio" class="is" name="why1856"   value="1">1</p><input type="radio" class="is" name="why31856"   checked  value="2">2</p>
怎么样获得这组radio被选中的值??

解决方案 »

  1.   


    <html>
    <head>
      <title>无标题页</title>
    <script src="http://code.jquery.com/jquery-latest.js"></script>  
    </head>
    <body>
    <input type="radio" class="is" name="why3185" value="0">0</p><input type="radio" class="is" name="why1856" value="1">1</p><input type="radio" class="is" name="why31856" checked value="2">2</p> <script>
    alert( $('.is:checked').val() )
    </script>  
    </body>
      

  2.   

    <html>
    <head>
        <script src="http://code.jquery.com/jquery-latest.js"></script> 
        <script type="text/javascript">
            $(document).ready(function () {
                $(".is").bind("click", function () {
                    alert($('.is:checked').val());
                })
            });
            
        </script>
    </head>
    <body>
        <input type="radio" class="is" name="why" value="0">0</p>
        <input type="radio" class="is" name="why" value="1">1</p>
        <input type="radio" class="is" name="why" checked="checked" value="2">2</p>
    </body>
    </html>楼主我认为你的代码似乎有点问题 - - 既然是一组Radio,name属性应该都一样,才能实现单选啊 = =
      

  3.   

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    window.onload = function() {
    var obj = document.getElementsByTagName('input');
    var demo = document.getElementById('demo');
    for (var i = 0; i < obj.length; i ++) {
    if (obj[i].className == 'is') obj[i].onclick = function() {
    var result = [];
    for (var j = 0; j < obj.length; j ++) if (obj[j].checked) result.push(obj[j].value);
    demo.innerHTML = result.join(',');
    }
    }
    }
    </script>
    </head><body>
    <input type="radio" class="is" name="why3185" value="0">0<br />
    <input type="radio" class="is" name="why1856" value="1">1<br />
    <input type="radio" class="is" name="why31856" checked value="2">2<div id="demo"></div>
    </body>
    </html>
      

  4.   

    <input type="radio" class="is" name="why3185" value="0">0<br />
    <input type="radio" class="is" name="why1856" value="1">1<br />
    <input type="radio" class="is" name="why31856" checked value="2">2有俩组的怎么办??
      

  5.   

     <input type="radio" class="is" name="why3185" value="0">0<br />
    <input type="radio" class="is" name="why1856" value="1">1<br />
    <input type="radio" class="is" name="why31856" checked value="2">2存放在value的值中,怎么取出来!!
      

  6.   

    你先得到这个组件对象,然后.value不就可以取出了吗.
      

  7.   

    取出来后就是<input type="radio" class="is" name="why3185" value="0">0<br />
    <input type="radio" class="is" name="why1856" value="1">1<br />
    <input type="radio" class="is" name="why31856" checked value="2">2
    这个!!
      

  8.   

    你一次只能取一组的值,如果有多组只能分开来取.
    <html>
    <head>
      <script type="text/javascript" src="jquery-1.4.1.min.js"></script>
      <style type="text/css">
      </style>
      <script type="text/javascript">
        $(function(){
      $("#Test").click(function(){
      alert($("input[class='is']:checked").val())
      });
    });
      </script>
    </head>
    <body>
    <form>
      <input type="radio" class="is" name="why3185" value="0">0</br>
      <input type="radio" class="is" name="why3185" value="1">1</br>
      <input type="radio" class="is" name="why3185" checked value="2">2</br>
      <input type="button" value="Test" id="Test"/>
    </form>
    </body>
    </html>