zoukankan      html  css  js  c++  java
  • 处理radio按钮

    
    <script src="jquery-1.6.4.js" type="text/javascript"></script>
    <input>aaaaaaaa
    <input name="Fruit1" type="radio" checked />苹果
    <input name="Fruit2" type="radio" checked  />橘子
    <input name="Fruit3" type="radio" value="" />香蕉
    <script>
    var checkedValue;
    var elements = document.getElementsByTagName('input');
    for (var i=0;i<elements.length;i++){
        console.log(elements[i].type);
        console.log(elements[i].name);
        console.log(elements[i].checked);
     if (elements[i].type == 'radio' && elements[i].name == 'Fruit2' && elements[i].checked){
        alert('aaaa');
     }
    }
    </script>
    
    
    <script src="jquery-1.6.4.js" type="text/javascript"></script>
    <input>aaaaaaaa
    <input name="Fruit1" type="radio" checked />苹果
    <input name="Fruit2" type="radio" checked  />橘子
    <input name="Fruit3" type="radio" value="" />香蕉
    <script>
    console.log($('input:radio[name="Fruit2"]:checked').val();
    </script>
    
    
    <script src="jquery-1.6.4.js" type="text/javascript"></script>
    <input>aaaaaaaa
    <input name="Fruit1" type="radio" checked />苹果
    <input name="Fruit2" type="radio" checked   />橘子
    <input name="Fruit3" type="radio" value="" />香蕉
    <script>
    if ($('input:radio[name="Fruit2"]:checked').val()){
    alert('aaa');
    };
    </script>
  • 相关阅读:
    bzoj 4017: 小Q的无敌异或
    [TJOI2014] Alice and Bob
    [TJOI2014] 上升子序列
    bzoj 3261: 最大异或和
    bzoj3087: Coci2009 misolovke
    bzoj3521: [Poi2014]Salad Bar
    bzoj4032: [HEOI2015]最短不公共子串
    bzoj1027: [JSOI2007]合金
    bzoj4637: 期望
    bzoj3919: [Baltic2014]portals
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348598.html
Copyright © 2011-2022 走看看