Alex Rivera | Logout

How to use jQuery to change the background color of a textbox?

Asked 2009-08-03T17:58:02.557
21

How to use jQuery to change the backgound color of a textbox?

Edit
Report

1 Answer

44

Better practice is to seperate UI from logic, in your case:

$("#textboxid").addClass("aClass");

If you really need it your way, then do the following:

$("#textboxid").css({"background-color": "color"});

Replace #textboxid with the desired selector, and color with the desired color.

Note the following does the same for one property:

$("#textboxid").css("background-color", "color");
answered 2009-08-03T18:00:17.277

Your Answer