![]() |
![]() |
![]() |
||||
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. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Too lazy to set a custom title
Industry Role:
Join Date: Mar 2004
Posts: 16,116
|
![]() Trying to code up a page to hide content on load, but expand once the header is clicked.
First header works, but the second and third are not at the moment. I need probably 15 different headers here. I'm no jQuery expert by far. http://barcritic.com/toggle3.html Anyone see what I'm doing wrong here? ![]() Code:
$(document).ready(function(){ $("#expanderHead").click(function(){ $("#expanderContent").slideToggle(); if ($("#expanderSign").text() == "+"){ $("#expanderSign").html("−") } else { $("#expanderSign").text("+") } }); }); Code:
<h4 id="expanderHead"> HEADER 1 <span id="expanderSign">+</span> </h4> <div id="expanderContent" style="display:none"> TEXT HERE </div> <h4 id="expanderHead"> HEADER 2 <span id="expanderSign">+</span> </h4> <div id="expanderContent" style="display:none"> TEXT HERE </div> <h4 id="expanderHead"> HEADER 3 <span id="expanderSign">+</span> </h4> <div id="expanderContent" style="display:none"> TEXT HERE </div>
__________________
Your Paysite Partner Strength In Numbers! StickyDollars | RadicalCash | KennysPennies | HomegrownCash |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,066
|
I am not a jquery expert but I think your problem is because of duplicate ids. I do believe that ids need to be unique.
Just a quick guess. .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 | |
Too lazy to set a custom title
Industry Role:
Join Date: Mar 2004
Posts: 16,116
|
Quote:
Here's the other one. Code:
jQuery(document).ready(function() { jQuery(".content").hide(); //toggle the componenet with class msg_body jQuery(".heading").click(function() { jQuery(this).next(".content").slideToggle(500); }); });
__________________
Your Paysite Partner Strength In Numbers! StickyDollars | RadicalCash | KennysPennies | HomegrownCash |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,066
|
Quote:
I have not used jquery much though so I am not sure of the best way to do it there. Doing it with just javascript on the onclick is fairly easy. .
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Too lazy to set a custom title
Industry Role:
Join Date: Mar 2004
Posts: 16,116
|
Hmm...going to try this http://jsfiddle.net/sYwER/5/
Just might work for what I need. Edit: Nope, unordered and ordered lists are not hidden. ![]()
__________________
Your Paysite Partner Strength In Numbers! StickyDollars | RadicalCash | KennysPennies | HomegrownCash |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,066
|
Quote:
Script: Code:
$(document).ready(function(){ $(".head").click(function(){ $(this).find(".expanderContent").slideToggle(); if ($(this).find(".expanderSign").text() == "+"){ $(this).find(".expanderSign").html("−") } else { $(this).find(".expanderSign").text("+") } }); }); Code:
<div class=head> <h4 class="expanderHead"> HEADER 1<span class="expanderSign">+</span> </h4> <div class="expanderContent" style="display:none"> TEXT HERE </div> </div> <div class=head> <h4 class="expanderHead"> HEADER 2 <span class="expanderSign">+</span> </h4> <div class="expanderContent" style="display:none"> TEXT HERE </div> </div> <div class=head> <h4 class="expanderHead"> HEADER 3 <span class="expanderSign">+</span> </h4> <div class="expanderContent" style="display:none"> TEXT HERE </div> </div>
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Too lazy to set a custom title
Industry Role:
Join Date: Mar 2004
Posts: 16,116
|
Awesome!!! Thanks, sarettah!
__________________
Your Paysite Partner Strength In Numbers! StickyDollars | RadicalCash | KennysPennies | HomegrownCash |
![]() |
![]() ![]() ![]() ![]() ![]() |