jquery background-color change on focus and blur

后端 未结 5 1769

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:52

    Tested Code:

    $("input").css("background","red");
    

    Complete:

    $('input:text').focus(function () {
        $(this).css({ 'background': 'Black' });
    });
    
    $('input:text').blur(function () {
        $(this).css({ 'background': 'red' });
    });
    

    Tested in version:

    jquery-1.9.1.js
    jquery-ui-1.10.3.js

提交回复
热议问题