Created
January 25, 2014 11:05
-
-
Save jsven69gist/8614824 to your computer and use it in GitHub Desktop.
jQuery: Set background-color on focus with addClass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add colorclass 'yellow' (background-color: #FFFF66) on focus to elements with class 'text' | |
$('.text').on('focus', function(event) { | |
$(this).addClass('yellow'); | |
}); | |
// Remove added colorclass 'yellow' on blur from elements with class 'text' | |
$('.text').on('blur', function(event) { | |
$(this).removeClass('yellow'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment