Jump to content

Folder Tree submenu not functioning properly


Guest missladyy

Recommended Posts

Guest missladyy

Hello everyone,

 

I have been working on a folder tree and have it just about completed. The only issue that I have is that the sub-menu does not function properly. When I open it and then click on one of the main menu options and then go back to the sub-menu it is still open. What should happen is that it closes when any other main menu option is clicked. Could someone review the code below and help me to understand what I need to do? Thanks.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head><title> 

</title> 

<script src="jquery/jquery-1.4.1-vsdoc.js" type="text/javascript"></script> 
<script src="jquery/jquery-1.4.1.js" type="text/javascript"></script> 


<script type="text/javascript"> 

function display(obj) { 
//collapse all div tags with ids 

$("div[id!=''][id!='" + obj.id + "']").each(function(i, obj) { 

var parent = $(obj).parent(); 
var div2 = $(parent).find("div")[1]; 


$(div2).slideUp("fast"); 
var div1 = $(parent).find("div")[0]; 
var img = $(div1).find("img")[0]; 
$(img).attr("src", "images/closedfolder.gif"); 

}); 



var parent = $(obj).parent(); 
var div2 = $(parent).find("div")[1]; 
$(div2).slideToggle("fast"); 
var div1 = $(parent).find("div")[0]; 
var img = $(div1).find("img")[0]; 
if ($(img).attr("src") == "images/closedfolder.gif") { 
$(img).attr("src", "images/openfolder.gif"); 


} 
else { 
if ($(img).attr("src") == "images/openfolder.gif") 
{ $(img).attr("src", "images/closedfolder.gif"); } 
} 


} 

//Submenu 

function ShowHide(){ 
$("#wuc").animate({"height": "toggle"}, { duration: 150 }); 
if ($("#wuc_image").attr("src") == "images/closedfolder.gif") { 
$("#wuc_image").attr("src", "images/openfolder.gif"); 


} 
else { 
if ($("#wuc_image").attr("src") == "images/openfolder.gif") { 
$("#wuc_image").attr("src", "images/closedfolder.gif");} 

} 


} 


</script> 
<style type="text/css"> 
body 
{ 
color:navy;font-family:Arial Narrow; 
} 
</style> 

</head> 
<body style="margin:0;padding:0;margin-left:10px;"> 
<form name="directions" method="post" action="" id="directions"> 

<div><br><br> 
<div> 
<div style='cursor:pointer;' onclick='display(this)' id='DrivingDirections'>  * Driving Directions</div> 
<div style='display:none;'>       
<a target='_blank' href='http://www.google.com'>- Google</a><br/>       
<a target='_blank' href='http://www.msn.com'>- MSN</a><br/>       
<a target='_blank' href='http://www.yahoo.com'>- Yahoo</a><br/>       
<a style='text-decoration:none; color:navy;' onclick='ShowHide(); return false;' href='#'>  * WUC</a> 
<div id='wuc' style='display:none;'>              
<a target='_blank' href='http://www.test.com'>- Test1</a><br/>              
<a target='_blank' href='http://www.test.com'>- Test2</a><br/>              
<a target='_blank' href='http://www.test.com'>- Test3</a><br/>              
<a target='_blank' href='http://www.test.com'>- Test4</a><br/><br/> 
</div> 
</div> 

</div> 

<div> 
<div style='cursor:pointer;' onclick='display(this)'id='CampusMaps'>  * Campus Maps</div> 
<div style='display:none;'>       
<a target='_blank' href='http://www.test.com'>- Test5</a><br/>       
<a target='_blank' href='http://www.test.com'>- Test6</a><br/>       
<a target='_blank' href='http://www.test.com'>- Test7</a><br/>       
</div> 

</div> 
</div> 



</form> 
</body> 
</html>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...