In order to have buttons with variable colors and a different hover color, I have to apply inline CSS. Since the hover color cannot be added using inline CSS, I need to use JavaScript. I attempted to achieve this using the .hover() function, but the colors disappear when hovering over the button.
Here is the code:
$('.btn').hover( function() {
var $hover = $('.btn').attr('data-hover');
$(this).css( "background", $hover );
}, function() {
var $color = $('.btn').attr('data-color');
$(this).css( "background", $color );
});
HTML:
<button class="btn wpb_btn-small" style="background:#00aff0;" data-color="#00aff0" data-hover="#0cbbfc">Button</button>