当前位置:编程学习 > JAVA >>

jquery获得焦点与失去焦点改变文本框背景图的写法

<script type="text/javascript">
        $(function () {
            //文本框样式切换
            $(".username").focus(function () {
                $(this).removeClass("usernamefocus").addClass("username");
            }).blur(function () {
                $(this).removeClass("username").addClass("usernamefocus");
            });
            $(".password").focus(function () {
                $(this).removeClass("password").addClass("passwordfocus");
            }).blur(function () {
                $(this).removeClass("passwordfocus").addClass("password");
            });
            //按钮样式切换
            $(".button_one").hover(
            function () {
                $(this).removeClass("button_one").addClass("button_two");
            },
            function () {
                $(this).removeClass("button_two").addClass("button_one");
            }
            );
            $(".button_two").hover(
            function () {
                $(this).removeClass("button_one").addClass("button_two");
            },
            function () {
                $(this).removeClass("button_two").addClass("button_one");
            }
            );
        });
    </script>
补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,