zoukankan      html  css  js  c++  java
  • JQuery 小结

    1。文本框的改变事件,可使用propertychange,例如:

    $("#txtDataDate").bind("propertychange",function(){

    });
    2。获取被选中RadioButton 的值
    var radio_value = $("input[@type=radio][checked]").val();
    3。下拉列表的改变事件,以及获得选中选项的值
    $("#下拉列表").change(function() {
    //获得选中项的value值
    var select = $(this).val();
      var checkText=$("#select_id").find("option:selected").text();  //获取Select选择的Text
    

    }).change();
    4。获取下拉列表DropDownList选中的值
    var ddl = $("#ddlDiaryType option:selected").text();//下拉别表

     5。Jquery绑定同一事件时,如要只执行一个事件,需要用  $("#txt").unbind();方法卸载事件,例如:

    代码
    $("#ddlType").change(function () {
    var now = new Date();
    var ADateNow = now.getYear() + "-" + (now.getMonth() + 1);
    var select = $(this).val();
    $(
    "#txtStartTime").unbind("focus");
    $(
    "#txtEndTime").unbind("focus");
    if (select == "") {
    var ADate = ADateNow;
    $(
    "#txtStartTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM' }); }).val(ADate);
    $(
    "#txtEndTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM' }); }).val(ADate);
    }
    else {
    ADate
    = ADateNow + "-" + now.getDate();
    $(
    "#txtStartTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM-dd' }); }).val(ADate);
    $(
    "#txtEndTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM-dd' }); }).val(ADate);
    }

    }).change();
    Top
    收藏
    关注
    评论
  • 相关阅读:
    云服务器迁移的那些事之一
    《编译原理》(第二版)第一章的学习笔记(一)
    vs 实用扩展
    SQL多的是,你不知道的事
    Entity Framework 批量插入 提速
    oracle 回收已删除的表
    发现一个奇怪的问题!
    看到易办网的希望...
    asp.net不认为数据库字段的空值为null
    什么是伪url?
  • 原文地址:https://www.cnblogs.com/smiler/p/1741372.html
Copyright © 2011-2022 走看看