Basically I have a form (id=”form”) with background-color: #000000; border: 1px solid #fff; I want to change it to background-color: #ffffff; border: 1px solid #000; once someone clicks on it. I tried using css:focusm but apparently it doesn’t work with forms. So is there a jQuery solution to this?
Also it is important that once user clicks away from the form (so when it is not in focus) it should return back to background-color: #000000; border: 1px solid #fff;
Basically I have a form (id=form) with background-color: #000000; border: 1px solid #fff; I
Share
I don’t believe that the
formelement can trigger thefocusevent so what you could do is set the color based onblurandfocusevent of all elements in the form.Markup:
jQuery:
the selector
input, selectwill select all inputs and drop downs in the page. You can further limit it by prefixing the form id as well if need be.