Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 05-23-2011, 05:43 AM   #1
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
div show/hide code...

I'm trying to do a div show/hide where I have 3-4 links and when I click on either the div or li attached to that link populates a Main div box. (i.e. main box is showing page chapters). I tried this with the tradition Tab show hide method but since my text links are off centered to the right wrapped around a gfx I need something where the links can be anywhere and not nested with a div like the tab method does.

any idea?
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-23-2011, 06:19 AM   #2
nation-x
Confirmed User
 
nation-x's Avatar
 
Industry Role:
Join Date: Mar 2004
Location: Rock Hill, SC
Posts: 5,370
I am not following what you want exactly, however, this is easily accomplished with jQuery. You can either use the toggle() method or add and subtract css classes with the click() method. The best way would be to add a classname to each of the links like this:

Code:
<div id="main"></div>
<a href="page1.html" class="pager">Page One</a>
<a href="page2.html" class="pager">Page Two</a>

<script>
jQuery(document).ready(function() {
    jQuery(".pager").click(function() {
        jQuery("#main").load(jQuery(this).attr('href'));
    });
});
</script>
In this example, I did something a little different than you described. When you click the link it will use ajax to load the content from the page in the link href attribute to the main div. I am assuming that this would accomplish the same goal without having to have all of the content included in the page by default.
nation-x is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-23-2011, 07:03 AM   #3
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by nation-x View Post
I am not following what you want exactly, however, this is easily accomplished with jQuery. You can either use the toggle() method or add and subtract css classes with the click() method. The best way would be to add a classname to each of the links like this:

Code:
<div id="main"></div>
<a href="page1.html" class="pager">Page One</a>
<a href="page2.html" class="pager">Page Two</a>

<script>
jQuery(document).ready(function() {
    jQuery(".pager").click(function() {
        jQuery("#main").load(jQuery(this).attr('href'));
    });
});
</script>
In this example, I did something a little different than you described. When you click the link it will use ajax to load the content from the page in the link href attribute to the main div. I am assuming that this would accomplish the same goal without having to have all of the content included in the page by default.
Thanks, I'll play around with this a bit. it's a wordpress site so I would like to preload all the content on the page to make it easier for onsite editing.
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.