javascript - random css animation on hover -


i have javascript when hover plays animation, have 4 different animations , randomize each time element hovered over

here's code

function firsthelp() {   document.getelementbyid('help-text').innerhtml = 'enter first name';   document.getelementbyid('help-box').style.animation ='greenhover 2s;';   document.getelementbyid('help-box').style.webkitanimation ='greenhover 2s';   } 

the other css animations bluehover orangehover , purplehover

    function getrandomanimation(duration) {        var possibleanimations = ["greenhover","bluehover","orangehover","purplehover"];       var randomnumber = math.floor((math.random()*4));       return (possibleanimations[randomnumber] + " " + duration || "");     } 

and use this:

  document.getelementbyid('help-box').style.animation = getrandomanimation('2s)'; 

Popular posts from this blog

Php - Delimiter must not be alphanumeric or backslash -

c# - How to change the "Applies To" field under folder auditing options programatically (.NET) -

c++ - Ambiguity when using boost::assign::list_of to construct a std::vector -