javascript - Check element's original value for automatic blur function? -


using javascript/jquery, want automatically change color value opposite on focus text inputs, return them original color on blur. far best i've come storing value in associative array id key , accessing way, don't want have go route. there better options?

thanks!

use jquery's .data() on element in question. it's built want do.

$(whatever).focus(function() {     var item = $(this);     item.data("origval", xxx); }).blur(function() {     var item = $(this);     var originalvalue = item.data("origval");     // whatever want original value }); 

fyi, might better create "active" class , use css control color:

$(whatever).focus(function() {     $(this).addclass("active"); }).blur(function() {     $(this).removeclass("active"); }); 

then, define normal color in css , special color when active class present. can add/remove "active" class , let css control color.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -