jquery对于输入框得到与失去焦点时的处理方法

Posted li1234567980

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jquery对于输入框得到与失去焦点时的处理方法相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <p>帐号:&ensp;<input type="text" name="" id="" value="" /></p>
        <p>密码:&ensp;<input type="text" name="" id="" value="" /></p>
    </body>
</html>
<script src="jquery-3.4.1.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    // focus() 输入框得到焦点时的处理
    // bulr()  输入框失去焦点时的处理
    $(function() {
        $(input:first).focus(function() {
            $(this).css(background, #eee);
        });
        $(input:first).blur(function() {
            $(this).css(background, #fff);
        });
        $(input:enabled).focus(function() {
            $(this).css(background, #eee);
        });
        $(input:enabled).blur(function() {
            $(this).css(background, #fff);
        });
    });
</script>

 

以上是关于jquery对于输入框得到与失去焦点时的处理方法的主要内容,如果未能解决你的问题,请参考以下文章