zoukankan      html  css  js  c++  java
  • 关于easyUI的datebox加失去焦点事件即click、blur等

    想实现日期框easyui-datebox手动输入值,手动输入失去焦点判断输入值是否合法 

    例如<input id="txtDate" type="text" class="easyui-datebox" />  直接$("#txtDate").blur(){}没有反应。因为加载日期控件dom的时候多了很多其他控件所以定位具体控件的时候有点问题。

    经自己测试和大神解答,发现有两种方法,直接上代码(简单测试例,没有写判断日期是否合法):

    <!DOCTYPE html>
    <html>
    <head>
    <script src="jquery-1.7.2.min.js"></script>
    <script src="jquery.easyui.min.js"></script>
    <link href="easyui.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
     <input id="txtDate" type="text" class="easyui-datebox" />  
    
    </body>
    
    </html>
    <script>
        $(function () {
            //自己测试
            $("#txtDate").next("span").children(":first").blur(function(){
                alert($("#txtDate").datebox('getValue'));
            });
            //大神提供
            $("#txtDate").datebox("textbox").blur(function(){
                alert($("#txtDate").datebox('getValue'));
            });
        });
    </script>
  • 相关阅读:
    使用python写天气预告
    beef配合ettercap批量劫持内网的浏览器
    html布局
    python 使用paramiko模块上传本地文件到ssh
    mysql一些函数的记录
    python与ssh交互
    html笔记4
    html笔记3
    html笔记2
    html笔记1
  • 原文地址:https://www.cnblogs.com/minzhousblogs/p/5474373.html
Copyright © 2011-2022 走看看