jffy
jffy

Reputation: 37

Replacing a jquery function with my own (wording?)

Didn't know how to word this better and couldn't find an answer through some searches.

I'm just wondering if I can replace: $("#someid").hover(function() {}); with my own function in place such as: $("#someid").hover(myfunction() {});

This has probably been answered and I'm just terrible at searching but any help would be greatly appreciated. Thanks

Upvotes: 0

Views: 39

Answers (1)

Turnip
Turnip

Reputation: 36642

Sure you can...

$('#someID').hover(myFunc);

function myFunc() {
    $('#someID').css('color','red');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<div id="someID">HOVER ME</div>

Upvotes: 4

Related Questions