jQuery .css('backgroundColor') issue -


i've got wee issue code. i've got bunch of class elements different background colors, named 'jq'. animate background color on hover , revert original color: .css('backgroundcolor') should color of given div hovered , jq class. instead, div background reverted white. here's code:

$(document).ready(function(){                $(".jq").hover(              var bgcol = $(this).css('backgroundcolor');                 function(){                    $(this).animate({                           backgroundcolor: "#eaeaea",                      color:"#333"                   },trans);                 },                 function() {                         $(this).animate({                     backgroundcolor:'bgcol',                      color:"#888"                   },trans);                 });                      }); 

there syntactical errors here

$(document).ready(function(){        $(".jq").hover(          function(){              var bgcol = $(this).css('backgroundcolor');             $(this).animate({                      backgroundcolor: "#eaeaea",                 color:"#333"             }, trans).data('hoverbackground', bgcol);         },         function() {                   $(this).animate({                 backgroundcolor: $(this).data('hoverbackground'),                 //backgroundcolor: "#efefef",                 color:"#888"             }, trans).removedata('hoverbackground');         });          }); 

demo: fiddle


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -