Is there a way to modify this function so that the classes of my links continuously change colors while I hover over them, rather than changing only once?
<script type="text/javascript">
$(".nav a").hover(function(e){
var randomClass = getRandomClass();
$(e.target).attr("class", randomClass);
});
$(".text a").hover(function(e){
var randomClass = getRandomClass();
$(e.target).attr("class", randomClass);
});
function getRandomClass(){
var classes = new Array("green", "purple", "teal", "violet", "pink", "red", "yellow", "blue", "magenta", "orange");
var randomNumber = Math.floor(Math.random()*11);
return classes[randomNumber];
}
</script>
Any suggestions on how I can achieve this effect would be greatly appreciated. Thank you!