I am trying to make a button for my website, which has a changing color hover effect. It can simply be done in css in this way:
.button{
color: green;
}
.button:hover {
background : green;
color: black;
}
However, I wanted to give this a nice transition using JQuery (since I'm trying to learn it). Here's one of the codes I've tried so far:
$(function() {
$('.button').on('mouseover', function() {
$(this).css({
"background" : "green",
"color" : "black",
})
})
})
I've tried it in so many other ways, like using the "hover" function instead of "on(mouseover)", using the addClass method, and so on. But in all of those, nothing happens when I hover the mouse on the button. Is there any easy way to do this?
})at the end of your script, then try again.