Wrapping it in $(window).resize(function(){})
won't work, as you'd be binding the handlers multiple times on hover.
What you could do is move the document.documentElement.clientWidth > 900
logic to inside the hover
handlers. So it'd look more like
$('.menu-item-2477').hover(
//Hover in function
function(){
if (document.documentElement.clientWidth > 900) {
...
}
},
//Hover out function
function(){
if (document.documentElement.clientWidth > 900) {
...
}
}
});
This way it will check the window size on every event, and perform different logic based on that. Nothing will happen on the resize of the window, as it checks only when it needs to know.