jQuery Change - do it as the user types?
I have an input box:
<input placeholder="your business name" name="bizzname" id="bizzname" class="placeholder" />
and I have some jquery for it:
$('#bizzname').change(function() {
$('#bizzname').css({"background":"","border":"1px solid #AAAAAA"});
});
Basically, I have it set so when the submit button is clicked, any fields which haven't been changed, their border and background are s开发者_如何学Pythonet.
I have created the above jquery function to change the background and border back to default once the field has been changed. It works almost perfectly, although I want it to run in real time, so that the border and background are changed on key press instead of when they change it and then select out of the input box? How can I achieve this within my jquery?
Replace the change
event with the keyup
event:
$('#bizzname').keyup(function() {
$('#bizzname').css({"background":"","border":"1px solid #AAAAAA"});
});
精彩评论