jquery 弥补ie6不支持input:hover状态

<!doctype html>
<html>
    <head>
    <meta charset="utf-8">
    <title>jquery 弥补ie6不支持input:hover状态</title>
    <style type="text/css">
    input{border:1px solid #eee;}
    input:focus{border:1px solid #ccc;}
    .focus{border:1px solid #ccc;}
    </style>
    <script type="text/javascript" src="jquery-1.11.1.min.js"></script>
    </head>

    <body>
        <form action="#" method="get">
            <label for="name">用户名</label>
            <input id="name" type="text"/>
            <label for="pass">密码</label>
            <input id="pass" type="text"/>
        </form>
        <script type="text/javascript">
        $(function(){
            $(":input").focus(function(){
                $(this).addClass("focus");
            }).blur(function(){
                $(this).removeClass("focus");
            });
        });
        </script>
    </body>
</html>

posted @ 2015-08-10 16:50  甜甜酱  阅读(165)  评论(0)    收藏  举报