Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-10-2012, 08:07 PM   PM User | #1
vinayedit
New to the CF scene

 
Join Date: Feb 2012
Location: MUMbai
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
vinayedit is an unknown quantity at this point
Smile Hide and Show text/content - pls Help!

Hello friends,

being great over here and feeling glad to be part of the Codingforums.com
its really really great pleasure here..
this is my first post here.

I am getting bit problem in html.
I am getting small problem and I am sure you all are help me out..

Kindly please show me how to hide and show content in html
once i click content will show and if i click again content will be hide..

Please if anyone know pls revert here (Waiting for reply)

Thanks

Vinay
vinayedit is offline   Reply With Quote
Old 02-10-2012, 08:36 PM   PM User | #2
dylanbaumannn
Regular Coder

 
Join Date: Feb 2012
Location: Nebraska, USA
Posts: 132
Thanks: 8
Thanked 19 Times in 19 Posts
dylanbaumannn is an unknown quantity at this point
Hello Vinay,

Welcome to CodingForums.com, we're glad to have you here

There is multiple ways to go about what you want actually, however, I'm not sure exactly how you'll be implementing this into your code or what you'll be applying this to.

Below is a way of achieving this using CSS styling for <li>'s:

HTML
Code:
<ul>
   <li class="show">
     <p>item shown</p>
   </li>
   <li class="hide">
      <p>item hidden</p>
   </li>
</ul
CSS
Code:
.show{ display: block;}	
.hide{ display: none;}

Last edited by dylanbaumannn; 02-10-2012 at 08:40 PM..
dylanbaumannn is offline   Reply With Quote
Old 02-10-2012, 08:46 PM   PM User | #3
vinayedit
New to the CF scene

 
Join Date: Feb 2012
Location: MUMbai
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
vinayedit is an unknown quantity at this point
HI dylan thanks for such quick reply..

but i need something different

i need one href link where i click then text content will show on the page
and if click on that same link that text content will hide again..
did u get me what i m trying to say?

i have some code where this can be possible but they have some problem like where the text content shown already on the page.. which is not required in my task i need hide text already and whe i click then it will show..

like that
vinayedit is offline   Reply With Quote
Old 02-10-2012, 08:50 PM   PM User | #4
dylanbaumannn
Regular Coder

 
Join Date: Feb 2012
Location: Nebraska, USA
Posts: 132
Thanks: 8
Thanked 19 Times in 19 Posts
dylanbaumannn is an unknown quantity at this point
So you need it to be hidden by default when the page first loads? Also, what kind of container are you using to display the text? (divs, li's, tables, etc)?

If you're using <li>'s here is an excellent method for hiding/showing them
http://code.stephenmorley.org/javasc...apsible-lists/
dylanbaumannn is offline   Reply With Quote
Old 02-10-2012, 08:56 PM   PM User | #5
vinayedit
New to the CF scene

 
Join Date: Feb 2012
Location: MUMbai
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
vinayedit is an unknown quantity at this point
Quote:
Originally Posted by dylanbaumannn View Post
So you need it to be hidden by default when the page first loads? Also, what kind of container are you using to display the text? (divs, li's, tables, etc)?

If you're using <li>'s here is an excellent method for hiding/showing them
http://code.stephenmorley.org/javasc...apsible-lists/

your first question is right.. i need hidden by default

i m using tables on the page..

<li> tag not required its like href link

like eg. suppose click here is link when i press on click here that content will show below the click here.. and when i press again that click here that content will hide again.. like that..
vinayedit is offline   Reply With Quote
Old 02-10-2012, 09:03 PM   PM User | #6
dylanbaumannn
Regular Coder

 
Join Date: Feb 2012
Location: Nebraska, USA
Posts: 132
Thanks: 8
Thanked 19 Times in 19 Posts
dylanbaumannn is an unknown quantity at this point
oh ok, I understand now.

<li>'s do NOT support href's you are correct there, but you can put an <a> tag inside of them in order to achieve the href. Would that work for you?

Code:
<ul>
   <li>
     <a href"#">Click HERE</a>
   </li>
</ul>
dylanbaumannn is offline   Reply With Quote
Old 02-10-2012, 09:09 PM   PM User | #7
vinayedit
New to the CF scene

 
Join Date: Feb 2012
Location: MUMbai
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
vinayedit is an unknown quantity at this point
Quote:
Originally Posted by dylanbaumannn View Post
oh ok, I understand now.

<li>'s do NOT support href's you are correct there, but you can put an <a> tag inside of them in order to achieve the href. Would that work for you?

Code:
<ul>
   <li>
     <a href"#">Click HERE</a>
   </li>
</ul>
no not actually, its not work


Quote:
<a href="javascript:hideshow(document.getElementById('adiv'))">Click here</a>

<script type="text/javascript">
function hideshow(which){
if (!document.getElementById)
return
if (which.style.display=="block")
which.style.display="none"
else
which.style.display="block"
}
</script>

<div id="adiv" style="font:24px bold; display: block">Now you see me</div>
this is the code i m using but here the "Now you see me" displays before
which is i dont need.
vinayedit is offline   Reply With Quote
Old 02-10-2012, 09:10 PM   PM User | #8
dylanbaumannn
Regular Coder

 
Join Date: Feb 2012
Location: Nebraska, USA
Posts: 132
Thanks: 8
Thanked 19 Times in 19 Posts
dylanbaumannn is an unknown quantity at this point
ohhhh ok, you're using Javascript to define and control how it functions. This thread was posted in the 'HTML & CSS' section so I was trying to solve it using HTML/CSS
dylanbaumannn is offline   Reply With Quote
Old 02-10-2012, 09:14 PM   PM User | #9
vinayedit
New to the CF scene

 
Join Date: Feb 2012
Location: MUMbai
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
vinayedit is an unknown quantity at this point
Quote:
Originally Posted by dylanbaumannn View Post
ohhhh ok, you're using Javascript to define and control how it functions. This thread was posted in the 'HTML & CSS' section so I was trying to solve it using HTML/CSS


hahah what a fun!
its my first thread so its gone here anyway..
but i need concrete solution what say!
vinayedit is offline   Reply With Quote
Old 02-11-2012, 03:25 PM   PM User | #10
vinayedit
New to the CF scene

 
Join Date: Feb 2012
Location: MUMbai
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
vinayedit is an unknown quantity at this point
anyone anyone..??

have any info about this issue..
vinayedit is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:32 AM.


Advertisement
Log in to turn off these ads.