Solved

javascript code

Posted on 2011-09-29
10
190 Views
Last Modified: 2012-05-12
Hi,

Does anyone have or know of some code that would do the something similar to this .gif image

where the user click on the errow it will drop down and when they click on it again it will go back up just like ebay home page.  

Thank you
sample.gif
0
Comment
Question by:lulu50
  • 6
  • 4
10 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 36815802
here is a sample using jQuery
<html>
<head>
			<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript" ></script>
<style>
	.divCollapsablePanel {cursor:pointer}
</style>
	
<script>
$(document).ready(function() {
	$(".divCollapsablePanel").click(function(){$("div",this).toggle(1000);});
});
</script>
</head>
<body>

<div class="divCollapsablePanel">
	Error
<div style="display:none">
	error details
	<ul>
		<li>error 1</li>
		<li>error 2</li>
		<li>error 3</li>
	</ul>
</div>
</div>

<div class="divCollapsablePanel">
	Stack
<div style="display:none">
	Stack details
	<ul>
		<li>Stack 1</li>
		<li>Stack 2</li>
		<li>Stack 3</li>
	</ul>
</div>
</div>

</body>
</html>

Open in new window

0
 

Author Comment

by:lulu50
ID: 36816517

I have two questions:

what if code.jquery.com removes all their files is that mean my menu will not work
anymore?

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript" ></script>

my second question.

I just found on the internet something similar to what I am looking for

http://javascript.internet.com/navigation/category-menus.html

the code you just posted it doesn't close when the user select a different category like the one in the javascript page.

is there a way to have only the clicked on category open and the rest closed?

0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36817238
what if code.jquery.com removes all their files is that mean my menu will not work anymore?

get the files and put into your web server and use that one, do not refer to jQuery site

is there a way to have only the clicked on category open and the rest closed?

yes, will prepare extended sample later...
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 36817404
here is the extended version
<html>
<head>
			<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript" ></script>
<style>
	.divCollapsablePanel {cursor:pointer}
	.divCollapsablePanelDetail {border:1px solid silver; padding:10; display:none}
</style>
	
<script>
$(document).ready(function() {
	$(".divCollapsablePanel").click(function(){
		$(".divCollapsablePanelDetail").hide();
		$(".divCollapsablePanelDetail",this).show(1000);
	});
});
</script>
</head>
<body>

<div class="divCollapsablePanel">
	Error
<div class="divCollapsablePanelDetail">
	error details
	<ul>
		<li>error 1</li>
		<li>error 2</li>
		<li>error 3</li>
	</ul>
</div>
</div>

<div class="divCollapsablePanel">
	Stack
<div class="divCollapsablePanelDetail">
	Stack details
	<ul>
		<li>Stack 1</li>
		<li>Stack 2</li>
		<li>Stack 3</li>
	</ul>
</div>
</div>

<div class="divCollapsablePanel">
	Other
<div class="divCollapsablePanelDetail">
	Other details
	<ul>
		<li>Other 1</li>
		<li>Other 2</li>
		<li>Other 3</li>
	</ul>
</div>
</div>

</body>
</html>

Open in new window

0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36817421
and you may ask for effect duration:

$(".divCollapsablePanelDetail",this).show(1000);
-->
$(".divCollapsablePanelDetail",this).show(); // to show immediately without any effect
-->
$(".divCollapsablePanelDetail",this).show(250); //1/4 sec for show effect
0
 

Author Comment

by:lulu50
ID: 36817559
HainKurt

do you know where I can get this library jquery-latest.min.js?

0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36817705
get it from here jquery.com
copy to your web server and reference to that library
make sure you use min version in your prod site for best performance...
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36817717
learn jQuery, at least basic things :)
0
 

Author Comment

by:lulu50
ID: 36817736
I got it

Thanks,

Yes, I will try to learn it
0
 

Author Closing Comment

by:lulu50
ID: 36817741
Great!!!! Thank you for helping me
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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…

825 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