[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

jQuery -- links -- on click show one div/hide the rest

Posted on 2009-04-02
3
Medium Priority
?
433 Views
Last Modified: 2012-08-13
Hi,
  Is there an available jQuery script where i can have 4 links.  When the user clicks on one of them, it shows a hidden div below the link (the div would have a photo and text).  When the user clicks on a different link, it shows the hidden div for this different link, AND hides all other divs, etc...
Thanks,
-Ron.
0
Comment
Question by:ron4721
[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
3 Comments
 
LVL 3

Accepted Solution

by:
asianandrew earned 2000 total points
ID: 24053585
I believe this is what you want: http://jqueryui.com/demos/accordion/
0
 

Author Closing Comment

by:ron4721
ID: 31565956
Thanks asianandrew!  Exactly what i was searching for!
0
 
LVL 5

Expert Comment

by:prokvk
ID: 24053712
Try this:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
<head>
    <title>Page title</title>
    
    <script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
    
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    
    <script type="text/javascript">
        $(function () {
            $('a').click(function () {
                $('div.desc').hide();
            
                $(this).next('div.desc').show();
                
                return false;
            });
        });
    </script>
</head>
 
<body>
 
    <a href="">Link 1</a>
    <div class="desc" style="display: none;">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent risus dui, dictum vel, pellentesque a, pharetra sagittis, risus. Praesent feugiat sollicitudin erat. Curabitur sollicitudin. Nam ultricies. Etiam iaculis dapibus ligula. Integer accumsan diam id elit. Cras luctus. Duis lacus erat, egestas 
    </div>
    
    <br />
    
    <a href="">Link 2</a>
    <div class="desc" style="display: none;">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent risus dui, dictum vel, pellentesque a, pharetra sagittis, risus. Praesent feugiat sollicitudin erat. Curabitur sollicitudin. Nam ultricies. Etiam iaculis dapibus ligula. Integer accumsan diam id elit. Cras luctus. Duis lacus erat, egestas 
    </div>
    
    <br />
    
    <a href="">Link 3</a>
    <div class="desc" style="display: none;">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent risus dui, dictum vel, pellentesque a, pharetra sagittis, risus. Praesent feugiat sollicitudin erat. Curabitur sollicitudin. Nam ultricies. Etiam iaculis dapibus ligula. Integer accumsan diam id elit. Cras luctus. Duis lacus erat, egestas 
    </div>
    
    <br />
    
    <a href="">Link 4</a>
    <div class="desc" style="display: none;">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent risus dui, dictum vel, pellentesque a, pharetra sagittis, risus. Praesent feugiat sollicitudin erat. Curabitur sollicitudin. Nam ultricies. Etiam iaculis dapibus ligula. Integer accumsan diam id elit. Cras luctus. Duis lacus erat, egestas 
    </div>
    
</body>
</html>

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

650 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