[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SetTimeOut with element

Posted on 2009-12-31
1
Medium Priority
?
194 Views
Last Modified: 2012-05-08

 I am trying to pass the element information into the timer.

This is how it should be works.
After mouse over the "show menu 0"
the other information below it should display after 500 milliseconds.
<html>
<head>
<script language="JavaScript" type="text/javascript">
//onmouseover show the drop down menu
	var timeout;
	function delay_master(elem,method){
		timeout = setTimeout("delay_master2(elem,method)",500);
	}
	function delay_master2(elem,method){
		alert("o"+elem)
		elem.childNodes[2].style.display=method
		clearTimeout(t);//clear timer after displayed
	}
	
	function AddClass(elem) {
		elem.className = "iehover";
		//elem.childNodes[2].style.display="block"; 
		delay_master(elem,'block');//passing command to delay master
	}
	function RemoveClass(elem) {
		elem.className = "";
		//elem.childNodes[2].style.display="none"; 
		delay_master(elem,'none');//passing command to delay master	
	}
        </script>

</head>
<body>                
<li  onmouseover="AddClass(this);" onmouseout="RemoveClass(this)" ><a href="search/?no_cat=y&amp;cat_id=1%26cat_name=show menu">show menu 0</a>
    <ul style="display:none">
    <li  style="clear:both; width:320px; margin-left:-20px;text-align:left; background-color:red">
    <p><a href="search/?cat_id=1&amp;cat_name=Apparel&amp;sub_cat_id=1&amp;sub_cat_name=Aprons">Aprons</a></p>
    </li>
    </ul>
</li>

<li  onmouseover="AddClass(this);" onmouseout="RemoveClass(this)" ><a href="search/?no_cat=y&amp;cat_id=1%26cat_name=show menu">show menu 1</a>
    <ul style="display:none">
    <li  style="clear:both; width:320px; margin-left:-20px;text-align:left; background-color:red">
    <p><a href="search/?cat_id=1&amp;cat_name=Apparel&amp;sub_cat_id=1&amp;sub_cat_name=Aprons">Aprons 2</a></p>
    </li>
    </ul>
</li>




</body>
</html>

Open in new window

0
Comment
Question by:jsdebugger
1 Comment
 
LVL 6

Accepted Solution

by:
jello024 earned 500 total points
ID: 26154674
setTimeout will fire outside the scope of the funtion it was called in. So in this case elem and method would not be recognized.  Give the element an id and try this:

setTimeout("delay_master2(document.getElementById('" + elem.id + "'), '" + method + "')",500);
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question