zoukankan      html  css  js  c++  java
  • jQuery笔记

    //ID元素下的所有input,并设置为不可用
    $("input", $("#id")).attr("disabled"true);
    //设置name为test的checkbox是否为选中状态。返回值为true|false
    $("input[name='test']").attr("checked");
    //下拉列表值改变时触发
    $(document).ready(function () {
        $(
    "select").change(function () {
             alert($(
    this).val());
        })
    })
    //查找含有date-myself属性的input对象
    $(":input[date-myself]")
    //全选,取消全选
    $("#全选复选框ID").click(function () {
       $(
    "input[name='单个复选框name值']").attr("checked", $(this).attr("checked"));
    })

    //点击所有,全选选中。全选状态下,取消一个选择,全选取消
    var checkBoxCount = $("input[name='CalculateCheck']").length;
    $(
    "input[name='CalculateCheck']").click(function () {
            
    var checkedCount = $("input[name='CalculateCheck']:checked").length;
            $(
    "#CalculateChkAll").attr("checked", checkBoxCount == checkedCount);
    })
    //juqery UI中,弹出层并加载指定页面。
    function ShowDialog(url) {
       $(
    "#DivID").dialog({
          autoOpen: 
    true,
           
    650,
          height: 
    500
          resizable: 
    true,
          title: 
    "测试",
          modal: 
    true,
          open: 
    function (event, ui) {
                  $(
    this).load(url + "?" + event.timeStamp, nullfunction () {
                  $(
    ":input:first").focus();
                  });
                },
          close: 
    function (event, ui) {
                    $(
    "#DivID").children().remove();
                    }
       });
    }
    //下拉列表选中的text值
    $("#下拉列表ID").find("option:selected").text();
    //获取下拉列表选中的索引
    $("#ddlregtype ").get(0).selectedindex

    //获取下拉列表选中的value  
    $("#下拉列表ID").val();

    //获取下拉列表选中的索引:
    $("#下拉列表ID").get(0).selectedindex;

    //设置下拉列表选中的索引(index为索引值):
    $("#下拉列表ID").get(0).selectedindex=index;

    //设置下拉列表选中的value:
    $("#下拉列表ID").attr("value","normal");
    $("#下拉列表ID").val("normal");
    $(
    "#下拉列表ID").get(0).value = value;
     
    //设置下拉列表选中的text:
    var count=$("#下拉列表IDoption").length;
    for(var i=0;i<count;i++)  
    {        
        
    if($("#下拉列表ID").get(0).options[i].text == text)  
            {  
                $(
    "#下拉列表ID").get(0).options[i].selected = true;  
                
    break;  
            }  
    }

    $(
    "#下拉列表ID option[text='jquery']").attr("selected"true);
     
    //设置下拉列表option项:

    //添加一项option
    $("#下拉列表ID").append("<option value='value'>text</option>");
     
    //在前面插入一项option 
    $("#下拉列表ID").prepend("<option value='0'>请选择</option>");

    //删除索引值最大的option 
    $("#下拉列表ID option:last").remove(); 
    //删除索引值为0的option
    $("#下拉列表ID option[index='0']").remove();
    //删除值为3的option
    $("#下拉列表ID option[value='3']").remove(); 

    //删除text值为4的option
    $("#下拉列表ID option[text='4']").remove(); 
     
    //清空 select:
    $("#下拉列表ID").empty();

        

     

    //jquery parseJSON
    var obj =  $.parseJSON(('{"name":"John"}');
    alert( obj.name === "John" );

     

    //英文字符转大写
    $('input[type="text"]').each(cfunction (n, v) {
            $(v).keyup(function (e) {

                 $(v).val($(v).val().toLocaleUpperCase());
            });
    });
  • 相关阅读:
    android手机rootROM下载地址
    mysql alter 语句用法,添加、修改、删除字段等
    java比较两个日期大小
    eclipse设置全局编码为UTF-8的方法
    Spring MVC 异步处理请求,提高程序性能
    ELK(ElasticSearch, Logstash, Kibana)搭建实时日志分析平台
    maven之发布项目到nexus【clean deploy命令】
    nexus-3本地下载jar的settipng.xml配置
    windows开启3306端口并用可视化工具访问远程mysql(授权访问)
    mysql 列转行,合并字段
  • 原文地址:https://www.cnblogs.com/dfzone/p/2077362.html
Copyright © 2011-2022 走看看