Solved

simple show hide this div depending on id

Posted on 2012-04-01
4
435 Views
Last Modified: 2012-08-14
i have 10 div's.

i am looking for a simple javascript that allows me to do the following.

i have a menu bar that says;
div 1
div 2
div 3
etc.

when i click div1, i want it to show div 1, and hide all the rest because they do not have
the div id# div1

the catch is, i want it linked to the div's class or id name
basicly like a onclick=get.this type code

so example, when clicking on the div 1 link,
the div 1 link will show the div with that related link# and id# div1

hopefully that explains it all.

thanks
0
Comment
Question by:webdott
4 Comments
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 300 total points
ID: 37794568
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37794850
var state=true;

$('document').ready(function() {
	$('div').click(function () {
		if(state == true) {
			$('div').hide();
			$(this).show();
			
			state = false;
		} 
		else {
			$('div').show();
			state = true;
		}
	})
})

Open in new window

0
 
LVL 16

Assisted Solution

by:HagayMandel
HagayMandel earned 200 total points
ID: 37795455
Your question is  not clear.
How can you hide divs and then click on them?
If you only want to get the div's data abs characteristics, check this sample: http://jsfiddle.net/EKZu3/
0
 

Author Closing Comment

by:webdott
ID: 37796112
Thank you both.

That is exactly what I am looking for.

HagayMandel - yours uses jquery which is nice to have that option.
I have to check to see if all mobile devices can use jquery. I believe
they can, I just have not checked into it yet.

Thanks again for the quick and exact answers!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

803 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