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>
  • 相关阅读:
    react学习笔记一
    获取客户端时间差
    ts
    Linux学习笔记
    vuex 基本使用
    SQL入门
    ios 中倒计时计算,时间戳为NaN
    git归纳总结
    JS原型对象
    vue笔记
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348598.html
Copyright © 2011-2022 走看看