Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 How do i hide and show div?

views
     
puaka_astro
post Mar 19 2009, 08:03 PM

Casual
***
Junior Member
331 posts

Joined: Jun 2007
From: Isketambola


try learning jquery, its much easy using jquery. here is some example on jquery. jquery is a javascript too,

CODE

<script type="text/javascript" src="/path/to/your/jquery.js"></script>
<script>
$(document).ready(function() {

    //trigger click event
   $('#myLinkId').click(function() {
        //this is eg. to show/hide your block
        $('#blockId').toggle();
   });

});
</script>

<body
[bad html removed] this can be anything(input,html tag), just assign the id to it -->
<input type="button" id="myLink" value="CLICK ME">

[bad html removed] this is your block to hide, assign the id -->

<div id="blockId" style="display:block; height:80px; width:80%;background:yellow;"> Hello Bro! Apa di atas? </div>

</body>



This post has been edited by puaka_astro: Mar 19 2009, 08:04 PM
puaka_astro
post Mar 20 2009, 12:35 AM

Casual
***
Junior Member
331 posts

Joined: Jun 2007
From: Isketambola


QUOTE(Andrew Lim @ Mar 19 2009, 10:19 PM)
Ah, I didn't know you could use toggle to do it.
Currently I'm developing a similar application, but I'm using css( "display", "none" ) and css( "display", "inline" ) to achieve the effect.
*
can too, toggle,show,hide can only switch between display:none/display:block. you will lose the "display:inline", instead you can use fadeIn() or fadeOut(), that will do the trick.

 

Change to:
| Lo-Fi Version
0.0154sec    0.71    6 queries    GZIP Disabled
Time is now: 15th December 2025 - 04:05 PM