Solved

simple show hide this div depending on id

Posted on 2012-04-01
4
438 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

830 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