zoukankan      html  css  js  c++  java
  • JQuery文本框焦点获得,失去控制![抄袭VS备忘]

     
     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <style type="text/css" media="screen">
    body { font: .9em/1.5 "Lucida Grande", "Trebuchet MS", "Bitstream Vera Sans", Verdana, Helvetica, sans-serif; }
    form { 20em; margin: 4em auto; }
    dt { clear: left; float: left; }
    dd { clear: right; margin-left: 6em; }
    input, textarea { 12em; border: 1px solid #ccc; }
    input:focus, textarea:focus { border: 1px solid #f00; background: #fcc; }
    .ie_hover { background: #ffc; }
    .ie_focus { border: 1px solid #f00; background: #fcc; }
    </style>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
        <title>JQuery文本框焦点获得,失去控制! </title>
        <script type="text/javascript" src="jquery.js"></script>
    </head>


    <script language="javascript">
    $(document).ready(function(){
    if ($.browser.msie){
    // $("input[@type='text'], input[@type='password'], textarea").focus(function(){$(this).addClass("ie_focus")}).blur(function(){$(this).removeClass("ie_focus")});

    $("#name").focus(function(){$(this).addClass("ie_focus")}).blur(function(){$(this).removeClass("ie_focus")});
    $("#name").focus(function(){$(this).addClass("ie_focus")}).blur(function(){name=$("#name").val();alert(name);});

    $("#username").focus(function(){$(this).addClass("ie_focus")}).blur(function(){n = $("#<%= username.ClientID %>")[0]; alert(n.value);});//服务器端控件元素
    }
    })
    </script>

    <body>
    <form runat="server">
    <dl>
       <dt>Name: <dt>
       <dd><input type="text" id="name"/></dd>
            <asp:TextBox ID="username" runat="server"></asp:TextBox>
                   
       <dt>Password: <dt>
       <dd><input type="password" id="password"/></dd>
       <dt>Textarea: <dt>
       <dd><textarea id="content"></textarea></dd>
    </dl>
    </form>
    </body>
    </html>

  • 相关阅读:
    tomcat启动脚本
    libcrypto.so.1.0.0内容丢失导致sshd无法运行解决方案
    linux最小安装
    linux下文件删除的原理
    Web服务器磁盘满故障深入解析
    入驻博客园,新的开始!!!
    其实我们都可以变得更加优秀!
    我的未来在哪里呢!
    学会选择
    SpringBoot+vue.js如何通过post方式实现导出excel
  • 原文地址:https://www.cnblogs.com/paulxie/p/1385059.html
Copyright © 2011-2022 走看看