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>
  • 相关阅读:
    10-3 集合之Set
    【Angular】排序
    【Mongous】
    【验证码】
    爬虫
    【DOM】
    年月日
    【Mocha】
    【Test】
    洛谷——P1823 音乐会的等待
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348598.html
Copyright © 2011-2022 走看看