lundi 12 septembre 2016

How to change color of element on hover and remove it when mouseout using jquery?

I found the following Snippet (color changes randomly on hover) But there is now mouseout state – i want the link color to change in its original state when not hovering the link.

Can anyone help me with this?

$(document).ready(function() {
    $( "p" ).mouseover(function() {
        $(this).css("color",getRandomColor());
    });

    function getRandomColor () {
        var letters = '0123456789ABCDEF'.split('');
        var color = '#';
        for (var i = 0; i < 6; i++) {
            color += letters[Math.floor(Math.random() * 16)];
        }
        return color;
    }
})

http://ift.tt/2cVGd3I




Aucun commentaire:

Enregistrer un commentaire