?
Solved

javascript code

Posted on 2011-09-29
10
Medium Priority
?
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 57

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 57

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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 57

Accepted Solution

by:
HainKurt earned 2000 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 57

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 57

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 57

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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

800 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