(051)jquery_事件_focus_blur

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
  <head>
    <title>dom_focus_blur.html</title>
    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
    <script type="text/javascript" src="../js/jquery/jquery190.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#mytext").bind("focus",function(){
                $("div").html("请输入您的姓名");
            }).bind("blur",function(){
                var value = $(this).val();
                if(value == null || value == ""){
                    $("div").html("输入的姓名为空");
                }
                else 
                {
                    $("div").html("输入姓名成功");
                }
            });
        });
    </script>
  </head>
  
  <body>
        <h3>表单中文本框的focus和blur事件</h3>
        <input id="mytext" type="text" value="" />
        <div></div>
  </body>
</html>

 

posted @ 2014-12-24 16:11  雪中飞雁  阅读(84)  评论(0)    收藏  举报