jquery - Change background color in CSS using a JavaScript function -
using css, i'm trying set background color of each element random color on hover:
:hover { background-color: "getrandom()"; } however, doesn't appear possible put javascript function call here. there alternative approach work?
here's page i'm working on: http://jsfiddle.net/fwkqq/3/
in jquery code:
$("*").hover( function(event) { $(this).css("background-color", getrandomcolor()); }, function (event) { $(this).css("background-color", "white"); } ); (you should remove :hover css element)
example: http://jsfiddle.net/jqsgq/
Comments
Post a Comment