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>

  • 相关阅读:
    leetcode Remove Linked List Elements
    leetcode Word Pattern
    leetcode Isomorphic Strings
    leetcode Valid Parentheses
    leetcode Remove Nth Node From End of List
    leetcode Contains Duplicate II
    leetcode Rectangle Area
    leetcode Length of Last Word
    leetcode Valid Sudoku
    leetcode Reverse Bits
  • 原文地址:https://www.cnblogs.com/paulxie/p/1385059.html
Copyright © 2011-2022 走看看