I'm using the following jQuery function:
$( selector ).hover( handlerIn, handlerOut ) Now, I want to delay the "handlerOut" part, but I can't seem to get this working. I've tried using delay() and setTimeout() but they both didn't work. I think it's a syntax thing. Here's my JS:
$(document).ready(function () { var menuItem2 = document.getElementById('#menu_item_2'); var menuItem3 = document.getElementById('#menu_item_3'); $('#menu_item_2').hover(function () { this.style.zIndex = "1"; menuItem3.style.zIndex = "0"; }); $('#menu_item_3').hover(function () { this.style.zIndex = "1"; menuItem2.style.zIndex = "0"; }, function () { $(this).delay(500).style.zIndex = "0"; }); }); HTML
<div id="menu_parent2"> <a href="#music"> <div class="menuItem" id="menu_item_2"> <h5>Music</h5> <hr> <p>Displays my music projects</p> </div> </a> <a href="#contact"> <div class="menuItem" id="menu_item_3"> <h5>Contact</h5> <hr> <p>Displays a contact form</p> </div> </a> </div>
$(this).delay(500).css({"z-index" : 0}). And this if you are planning on using jquery, then dont mix it with pure javascript.#menu_item_2gets slided over#menu_item_3using css, which is why I want to change thez-index.