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
Post a Comment