The callback hover() functions are already good friends with the this (jQuery Element Object reference), so all you need is to revoke the $(this)
function onHoverIn() {
$(this).css('background-color', 'rgba(193, 86, 10, 0.86)');
}
function onHoverOut() {
$(this).css('background-color', 'rgba(26, 13, 3, 0.26)');
}
$("button").hover(onHoverIn, onHoverOut);
You cannot pass arguments to arguments. That's what was wrong in your code:
.method( myFunz( this ) )
// ^argument ^argument :(
How's that $(this) is available in those Named Function Declarations?
jQuery .hover() Docs
.hover( handlerIn, handlerOut )
handlerIn
Type: Function( Event eventObject )
A function to execute when the mouse pointer enters the element.
handlerOut
Type: Function( Event eventObject )
A function to execute when the mouse pointer leaves the element.
so .hover() method accepts two function callbacks.
and exploring the jQuery code for the .hover() method:
hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
},
you can clearly see that it returns this (the Event eventObject) to maintain methods chainability (.hover().click().etc()) and to make for you accessible the this (Event eventObject) who triggered the event.
If (really, if) all you need is a :hover that changes a background-color
use CSS :)
button {
background-color : rgba(193, 86, 10, 0.86);
}
button:hover {
background-color : rgba(26, 13, 3, 0.26);
}