zoukankan      html  css  js  c++  java
  • JQuery常用代码收藏

    //选择被选中Radio的Value值
    $("input[name='radio_name'][checked]").val(); 
    
    //根据Value值设置Radio为选中状态
    $("input[name='radio_name'][value='要选中Radio的Value值'").attr("checked",true);  
    
    //选择被选中CheckBox元素的集合 如果你想得到Value值你需要遍历这个集合
    $("input[name='checkbox_name'][checked]"); 
    
    //遍历被选中CheckBox元素的集合 得到Value值
    $($("input[name='checkbox_name'][checked]")).each(function(){arrChk+=this.value + ',';});
    
    //获取一个CheckBox的状态(有没有被选中,返回true/false)
    $("#checkbox_id").attr("checked");
    
    //设置一个CheckBox的状态为选中(checked=true)
    $("#checkbox_id").attr("checked",true); 
    
    //设置一个CheckBox的状态为不选中(checked=false)
    $("#checkbox_id").attr("checked",false); 
    
    $("input[name='checkbox_name']").attr("checked",$("#checkbox_id").attr("checked"));
    
    //事件 当对象text_id获取焦点时触发
    $("#text_id").focus(function(){//code...});  
    
    //事件 当对象text_id失去焦点时触发
    $("#text_id").blur(function(){//code...}); 
    
    //使文本框的Vlaue值成选中状态
    $("#text_id").select(); 
    
  • 相关阅读:
    数组 例题解析
    第六章 数组
    循环控制 例题解析
    第五章 循环控制
    第四章 选择结构程序设计
    第三章 数据的输入与输出
    第一章 程序设计及C语言概述
    C 字符串类型例题讲解与实现字符串库函数
    0XX_javascript核心
    012品优购03
  • 原文地址:https://www.cnblogs.com/lsmsky/p/1997416.html
Copyright © 2011-2022 走看看