jquery background-color change on focus and blur

后端 未结 5 1787

I have the following problem: I have a form with three text input fields, and I want to change the background-color when one of the fields has focus, and get it set back whe

5条回答
  •  误落风尘
    2020-12-29 22:51

    What you are trying to do can be simplified down to this.

    $('input:text').bind('focus blur', function() {
        $(this).toggleClass('red');
    });
    input{
        background:#FFFFEE;
    }
    .red{
        background-color:red;
    }
    
    
    

提交回复
热议问题