zoukankan      html  css  js  c++  java
  • jQuery-对Radio/CheckBox的操作集合

    jQuery获取Radio选择的Value值:

    jQuery   C#   VB   C++   Java  
     
    jQuery设置Radio的Value值:


    语法解释:
    1. $("input[name='radio_name'][checked]").val();  //选择被选中Radio的Value值
    2. $("#text_id").focus(function(){//code...});  //事件 当对象text_id获取焦点时触发
    3. $("#text_id").blur(function(){//code...});  //事件 当对象text_id失去焦点时触发
    4. $("#text_id").select();  //使文本框的Vlaue值成选中状态
    5. $("input[name='radio_name'][value='要选中Radio的Value值']").attr("checked",true);  //根据Value值设置Radio为选中状态
    jQuery获取CheckBox选择的Value值:
    jQuery   C#   VB   C++   Java  
    全选/取消全选
     


    语法解释:
    1. $("input[name='checkbox_name'][checked]");  //选择被选中CheckBox元素的集合 如果你想得到Value值,你需要遍历这个集合
    2. $($("input[name='checkbox_name'][checked]")).each(function(){arrChk+=this.value + ',';});  //遍历被选中CheckBox元素的集合 得到Value值
    3. $("#checkbox_id").attr("checked");  //获取一个CheckBox的状态(有没有被选中,返回true/false)
    4. $("#checkbox_id").attr("checked",true);  //设置一个CheckBox的状态为选中(checked=true)
    5. $("#checkbox_id").attr("checked",false);  //设置一个CheckBox的状态为不选中(checked=false)
    6. $("input[name='checkbox_name']").attr("checked",$("#checkbox_id").attr("checked"));  //根据3,4,5条,你可以分析分析这句代码的意思
    7. $("#text_id").val().split(",");  //将Text的Value值以','分隔 返回一个数组
  • 相关阅读:
    python自学笔记
    mybatis审查要点
    session和cookie的简单理解
    linux命令
    [个人原创]关于java中对象排序的一些探讨(三)
    [技术翻译]Guava官方文档Ordering
    [个人原创]关于java中对象排序的一些探讨(二)
    [个人原创]关于java中对象排序的一些探讨(一)
    from 2666
    Euler Project question 34 in python way
  • 原文地址:https://www.cnblogs.com/catherineSue/p/5151904.html
Copyright © 2011-2022 走看看