javascript - Random Hover Effects -


how can randomize hover effects?

for example:

<p>test</p>  p:hover { background: yellow; }  p:hover: background: red; } 

please note above for-example only. question is, how can randomize hover effects, shows background:yellow; , background:red; once in random order on onmouseover?

there should not order, example: on first hover - 1 class added, on second - another. should completely random.

use following function random colors , use mouseover event change background color.

function getrandomcolor () {  var letters = '0123456789abcdef'.split('');  var color = '#';  (var = 0; < 6; i++) {      color += letters[math.floor(math.random() * 16)];  }  return color;     } })  $( "p" ).mouseover(function() { $(this).css("background",getrandomcolor()); }); 

please check fiddle.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -