Top

JavaScript Paragraph Toggle


Javascript Code
+ 0 likes
Please Register to submit score.
Average Score  8.0
Scores Submitted  3
Date Added  Jun 25, 2008
Last Updated  Jun 25, 2008
Tags  javascript  paragraph  toggle 

Introduction

I used this function on my latest website, found it came in handy and looked real nice;
Put this into any html page, the put this code for the bit that's to be toggled;

Code:
<p id="pname" style="display:none;">This is my shitty text lolz</p>


Now there's the paragraph, you need a link to toggle it visible, or not.

Code:
<a href="Javascript:toggle('pname');">Link Text</a>


This is REALLY effective when you use CSS with it, and it looks really pro :P

Grab the Code

Comments

  (9)  RSS
F*U*R*B*Y*
Comments: 551
 
Javascript Snippet:  JavaScript Paragraph Toggle
Posted on Jun 25, 2008 9:26 pm
Nice. I have used this method on my forums already but never the less nice

8/10 - Someone will find this very useful, i would if i hadn\'t already done it ;)
vaseline28
Comments: 134
 
Javascript Snippet:  JavaScript Paragraph Toggle
Posted on Jun 26, 2008 12:08 pm
Excellent Script! Just what I was looking for on my website, but a few points:

A: Does not seem to work when within <div></div> tags
B: Is there anyway to hide the link text when it is clicked?

9/10 If there\'s a solution to those, 10 straight away!
jonesy44
Comments: 907
 
Javascript Snippet:  JavaScript Paragraph Toggle
Posted on Jun 26, 2008 1:56 pm
No, i found it only worked with <p> not sure about <span> and as you say, doesnt work with <div>

I\'ll check it out and get back to you, but i am a JS idiot lol.

You could put the link text within a <p> so for instance;

Code:
<p id=\"paralink\" style=\"display:inline;\"><a href=\"Javascript: toggle(\'para\'); toggle(\'paralink\');\">Toggle</a></p>
<p id=\"para\" style=\"display:none;\">This is my shoot text lolz</p>


that should work.
F*U*R*B*Y*
Comments: 551
 
Javascript Snippet:  JavaScript Paragraph Toggle
Posted on Jun 26, 2008 5:01 pm
vaseline,

regarding the \"doesn\'t seem to work when within <div></div> tags\" i just tried it and it worked, perhaps post what you were trying and we could help
vaseline28
Comments: 134
 
Javascript Snippet:  JavaScript Paragraph Toggle
Posted on Jun 28, 2008 11:46 am
Simple as what I said, I tried to put it within <div></div> tags and no text showed up. It seems to have not worked for jonesy44 either.
F*U*R*B*Y*
Comments: 551
 
Javascript Snippet:  JavaScript Paragraph Toggle
Posted on Jun 28, 2008 11:17 pm
so you have

Code:

<div>Code & text here</div>

or
Code:

Code here
<div> text here</div>


or what?

????
vaseline28
Comments: 134
 
Javascript Snippet:  JavaScript Paragraph Toggle
Posted on Jun 29, 2008 5:24 am
I have tried both.
F*U*R*B*Y*
Comments: 551
 
Javascript Snippet:  JavaScript Paragraph Toggle
Posted on Jun 29, 2008 5:56 am
so just like that???

how about you show me EXACTLY what you have.........
vaseline28
Comments: 134
 
Javascript Snippet:  JavaScript Paragraph Toggle
Posted on Jun 29, 2008 6:06 am
It\'s OK thanks, I\'m using Hawkee\'s snippet just now, but thanks for the offer!

Please Register or Login to start posting comments.
Bottom