Show / Hide DIV According To Link URL

Mar 4, 2009

I am pretty new to JS but I've managed to create a function to show and hide a div according to a link's URL, but I am gonna have lots of url's and lots of div's to show and hide, its not a problem to show and hide them, the only trouble is that they stack, if I show div 1, and then press link 2 to show div 2, Div 2 is gonna be below div 1, and what I want is that when I click link 2 to hide div 1 or any other shown divs, I am sure its possible but i don't know how to do it. I think it would be possible by storing the id of the div in a variable, but the only problem is that when I call that function, the variable always changes so it would be a matter of storing the id in a variable outside the function, but i don't know how to do that, or what are the rules?

This is my code:
JS
function showHide(product) {
var el = document.getElementById(product);
el.className = (el.className == 'hide') ? '' : 'hide';
}

HTML
<div id="1" class="hide">Content of Div 1</div>
<div id="2" class="hide">Content of Div 2</div>
<a href="javascript:showHide('1');">Show Hide 1</a>
<a href="javascript:showHide('2');">Show Hide 1</a>

CSS
.hide {
display:none;
}

I need to have the javascript function call in href because of an applet I am using. In resume, the divs are hidden at the start, when I click one link, the div shows, when I click the other link I need the previous div shown to be hidden (class="hide"), and show the new div and so on.

View 4 Replies


ADVERTISEMENT

Hide/show Link Like Rapidshare

Jun 29, 2006

just wondering, anybody has script/tutorial that does the show link after 45 seconds like rapidshare? There's a counter and after 45 seconds it displays the link.

View 1 Replies View Related

JQuery :: Show / Hide Link Div?

Apr 13, 2009

I have multiple divs called article which have a show/hide link to toggle a div inside called articleBody. Problem is when I click the link all divs show/hide. The html structure is below:

<div class="article">
<p class="show"><a href="#">Hide [-]</a></p>
<div class="articleBody"><!-- Stuff i need to hide on click</div>
</div>

how I can toggle the text to say show/hide as well as just closing that one instance of div article rather than every instance on the page?

Thanks</textarea></p>
<input type='hidden' name='ID[4]' value='206852' />
<input type='hidden' name='URL[4]' value='http://forum.jquery.com/topic/direction-please-show-hide-from-single-link' />
<input type='hidden' name='CAT[4]' value='JQuery' />

[code]....

I have 11 elements with long description of each element of them. I decided to display the elements on the sidebar and the description of each one of them will be displayed on the body directly when the user clicks on the element.but the problem with this one is put the content (or description) inside the javascript code, and I want the description be on the HTML code to make it later on flexible for changes by the admin after putting the data including the description of these elements on the database instead of hard-coded style.

View 4 Replies View Related

JQuery :: Hide And Show Elements With Same Link?

Jun 16, 2011

$('a.showContent').click(function(e) {
e.preventDefault();
$(this).each(function(i) {
$(this).parent().parent().find('.hide').slideDown();

[code]...

is also not doing it..how do I hide elements with same link that I used to show them?

View 4 Replies View Related

JQuery :: Show Hide 'td' On Click Of A Link?

Feb 12, 2010

I have a table that contains information that is hidden within a 'td' element. Users can access this information if they wish by clicking on a link that is held in another 'td' element on the previous row (table structure below):

<table>
<tr>
<td><a href="#" class="install_toggle"

[code]....

View 1 Replies View Related

Show/Hide Link PLUS Text Change?

Jan 11, 2010

I can I take a code like this:

<script language="javascript">
function toggle() {
var ele = document.getElementById("toggleText");

[Code]....

But make it so you see "Show" before you click, then change the text to "Hide" once you click the link?

View 12 Replies View Related

Link Preview Show / Hide Div / Iframe

Sep 1, 2011

There are various widgets and plugins that show link preview via tooltip or iframe,So as I am trying to continuously improve web sites experience with new trends and web functionalities - thus it come the task for uniform link preview via div and iframe.

View 14 Replies View Related

Link Click To Hide / Show Series Of DIV

Jan 1, 2011

I'm basically trying to make it so a link click will hide and display a series of DIVs to make my site look a bit neater and more professional. The code I have WORKS, it can make a DIV appear and disappear easily enough but the issue I'm having is that it only works if you click the same link to show nad hide. Click a link to show a DIV then click another link and both will be visible.

But the only other code I tried to hide all but the selected DIV just results in my page becoming invisible (Its constructed with DIVs from top to bottom) so its not a suitable result. I'm basically after this: [URL]. Where you click on the link (in this case an image) and it shows what you need. I did try searching through their HTML and code but their javascript file appears as one long string to me so its hard to find any real useful detail.

This is the code I have at the moment:
Code JavaScript:
function showHide(shID) {
if (document.getElementById(shID)) {
if (document.getElementById(shID).style.display != 'block') {
document.getElementById(shID).style.display = 'block';
}else {
document.getElementById(shID).style.display = 'none';
}}}

And this is my current page in practice. [URL]. I'm assuming I might need an array but I need to stop it picking on every DIV and only the DIVs in my content area.

View 6 Replies View Related

Show/hide Multiple Elements With One Link Using Javascript

Oct 14, 2005

How can i do this i already have a function to show/hide elements with one link but how can i show/hide multiple elements

Here is the script:

function obj_ref(object)
{
if (document.getElementById)
{
return document.getElementById(object);
}
else if (document.all)
{
return eval('document.all.' + object);
}
else
{
return false;
}
}

function obj_toggle(object, open_close, open_text, close_text)
{
var object = obj_ref(object);
var icone = obj_ref(open_close);

if( !object.style )
{
return false;
}

if( object.style.display == 'none' )
{
object.style.display = ''
icone.innerHTML = close_text;
}
else
{
object.style.display = 'none'
icone.innerHTML = open_text;
}
}

View 4 Replies View Related

How To Link To A Page With Different Default Show / Hide Tab Showing

Aug 2, 2009

I'm not allowed to post a link yet since I'm a newbie. But the page is here: tinyurl dot com /m8ajyp

This page (and others on the site) use javascript to show/hide some divs in order to have a tab-like interface.

Is there any way to link to this page with the "Past Events" div showing as the default? Right now you can see that "Coming Events" shows on page load. And that's the way we want it most of the time.

But there are places in the site where I'd like to link specifically to this page with the "Past Events" div showing on page load.code...

View 7 Replies View Related

Show/hide Certains Divs When A Link Is Clicked?

May 23, 2011

I need to show/hide certains divs when a link is clicked.These are my divs:

div1
div2
div3
div4
div5

I will have several links. Depending on which link is clicked it will hide/show several divs simultaneously For example, if link1 is clicked it will hide div1, div2 and div3 and show div4 and div5.

View 10 Replies View Related

Toggle Link Text And Show / Hide ID Onclick

Apr 20, 2010

I am trying to create a Link that changes its currently displayed text and also toggles the css.display property from inline to hidden. I'm sure there are solution outs there btu I have not been able to find one that does both functions with one click properly and is also easy to implement for people not as familiar with html and javascript. Obviously I am trying to create a show more, show less type link. currently this often shared code works fine to change the current state of the target ID's css.display from none to inline. My end goal is to be able to not only toggle the display of the LONG1 div but to also change the innerhtml of 'short1' from "Show More" to "Show Less".I am still learning about JS so Im really rough around the edges. I tried some different techniques btu I dont ahev them posted on my work pc.

View 14 Replies View Related

JQuery :: Repeated Show/hide - P.hidden Must Be Closed By A Link Within Himself

Jun 7, 2010

Here's what I want to do:

1. Have a link (p.advert a.toggle) inside p.advert that tells p.hidden to show itself and at the same moment hides that link (p.advert a.toggle).

2. p.hidden must be closed by a link within himself.

3. When I close p.hidden, I need p.advert a.toggle to become visible so that the user can see p.hidden again by clicking on p.advert a.toggle.

4. The code must be reusable many times on the same page.

At the moment I can't get point 3 to work.

View 4 Replies View Related

Show / Hide Div - When The Box Has Been Hidden By The Close Link It Will Not Be Shown By The Links

Jul 20, 2011

I have four links which show a div and when you select another link it closes the current div and shows the new one. I'm trying to add a 'Close' button within the currently open div which obviously will hide the div and allow it to be opened again by selecting a link.

Code:

HTML Code:

My problem is that when the box has been hidden by the close link it will not be shown by the links.

View 2 Replies View Related

Jquery :: Show And Hide Script When Clicked On Link Of Particular Section?

Dec 16, 2011

I have working code to Show/Hide content when clicked on link of particular section:

var showText="Show content FAQ1";
var hideText="Hide content FAQ1";

1. How to do link on particular Title and show this description like Description1, Description2 etc.

2. How to open some sections in advance inside Javascript?

Working code is the following using Jquery jqueryV1.4.4:

PHP Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">[code]....

View 1 Replies View Related

JQuery :: Anchor Link List Show / Hide Content ID On Mouseover

Jun 8, 2011

I have a list item, where only some of the items are linking to a quote from the client. The quotes are in another list, where each list item has an id corresponding to the client link. I want to show the client quote when you roll over the client anchor link. Currently when I mouseover it's showing nothing.

Here's my HTML
<!--client list-->
<ul id="clientList">
<li>no quote Client /</li>
<li><a href="#client1">Client 1</a> /</li>
<li>no quote Client /</li>
<li><a href="#client2">Client 2</a> /</li>
</ul>
<!--client testimonials--> .....

At the moment, when I mouseover one of the anchored client links, the content disappears, so it's not showing the correct client quote <li>.
$(document).ready(function() {
// see if the requested page url contains an anchor '#'
var hash = window.location.hash.substring(1);
// if no anchor, show the default blockqoute
if(!hash){
var id = 'default';
}else{
var id = hash;
} .....

View 2 Replies View Related

Show / Hide Div Layer / Change Link Color / When Radio Button Is Selected

Aug 16, 2010

I am trying to develop an exam system.Find my code below.I request you to copy the code and save it as an html file .I have 2 problems:

1. Kindly notice that when the quiz is loaded,it shows both the questions by default.I want only question 1 to be visible when the quiz loads.What happens presently is that ,both questions are visible even after I click on the link
Q.1( referring to question 1).However,when I click on
Q. 2,then only question 2 can be seen and then(after clicking on Q.2) if I click on Q.1,then only question 1 can be seen

What I want is that when the page loads only question 1 is visible.Then when I click on Q.2,I can see only question 2 and when I click on Q.1, I can see only question 1.I later plan on adding many questions,so it should be a general solution rather than a solution good only for 2 questions.

2.Also,what I want is that,if someone selects any of the answers of a particular question,it's link color should turn green to indicate to the user that he answered that question.So for,instance,if I select an answer to the first question(select one of London,New York,Seattle,Washington,Chicago), the link Q.1 should turn green.

View 3 Replies View Related

JQuery :: Toggle Function - Hide/show Table When Hide/show Button Is Pressed

Sep 12, 2011

I am trying to hide/show table when hide/show button is pressed

Problem: The code works fine when I remove 'slow' from line 10. But with 'slow' in line 10 content of toggleButton doesnt change from Hide to Show when pressed.

Code:

View 1 Replies View Related

"Read More" Link / Button To Show / Hide Complete Text Field's Output Content

Jul 18, 2010

I have one long text field in HTML to feed text as input in my page. the entered text will be shown as output text after some operations.In this context, i need to display few text(say 200 chars) only and i need to provide READMORE link/button which would show me the complete content of that text field. I need to achieve this shortly!

View 2 Replies View Related

Show / Hide Won't Show In Nested List

Jan 22, 2009

I am having problems, basically I have a set of nested lists I need to show and hide

Code:
<ul id="smenu3"><ul id="smenu4">
<li>stuff here..</li>
<li>stuff here..</li>
<li>stuff here..</li>
</ul><ul id="smenu5">
[Code]...

I always want "smenu3" to show with "smenu4" and "smenu5" collapsed... When the user clicks the link, it calls a javascript function to show "smenu4" like so...

[Code]...

View 7 Replies View Related

Link To Show Hidden Div But Reset Others With Other Link?

May 28, 2009

I'm sure this has been brought up on these forums multiple times about showing and hiding div tags via links that you click on. The majority of ones that I found have you click a link to open the div and if you click the same link again, the div closes like it should.

But my problem involves multiple links and multiple div files that need to open the div assigned to it when clicked but also hide any previous divs that were shown with previous link clicks.

My Javascript in the head

Code:
<script type="text/javascript">
<!-- Show arrow on link click
function showArrow(id) {

[Code]....

View 2 Replies View Related

Hide A Div/link Without Any Id

Jan 22, 2010

look at following html:

<div style="padding-bottom: 4px;">
<img height="10" align="absmiddle" width="10" src="images/1rightarrow.gif"> <a class="mainmenu" href="affiliate-settings.php">Inoutscripts Affiliate Id </a>
</div>

way to hide this div or link in javascript/jquery? I can't make use of class as well because there are several links as well with the same class name.

View 7 Replies View Related

Hide/show <div>

Aug 11, 2005

I am trying to hide some form elements in a form by default and show/hide
depending on which radio button is clicked. This is what I have but it is
not working: Code:

View 2 Replies View Related

Show/hide

Sep 6, 2005

I'd like to have a show/hide widget on my web site, kind of like "show
details" / "hide details" in Google Groups. Is there a tutorial
explaining how to make them? Google's is a bit complex and it's easy to
get something wrong. If the browser does not support the required
features, I want it to generate a completely static page with the
"details" shown automatically.

View 3 Replies View Related

Show A Div And Hide Another?

Oct 26, 2009

Check this code:

<a>text</a>
<div id="pkg">pkg</div>
<div id="table_pkg">table_pkg</div>

I'd like to show table_pkg and hide pkg when I click on <a>text</a>. How can I do?

View 3 Replies View Related

Show One Div But Hide Another?

Apr 8, 2009

I am using some simple javascript to show and a hide a div

Code:
function showHide(d) {
if (document.getElementById(d).style.display == "none")
{
document.getElementById(d).style.display = "block";

[Code]...

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved