Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Show/Hide Link - HTML and CSS [closed]

Can anyone help me with this problem? I am new using CSS/HTML. I want to create a link div to hide and show its contents. What am I doing wrong?

Here is my code:

html

<a href="#" id="hideShow">My Title</a>
<div id="message" style="visibility:hidden; border: 1px solid #777; width: 400px; padding: 1%;">
    Blah Blah Blah Blah
</div>


<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript"> 

    $("#hide").toggle(
        function(){$("#message").show();},
        function(){$("#message").hide();},
});

</script>  

Thanks...

like image 428
user3132508 Avatar asked Apr 22 '26 06:04

user3132508


1 Answers

Try this,

$("#hideShow").click(function(){
   $("#message").toggle();
});

Note: Your id of "My Title" a tag is hideShow & not hide, also use display:none instead of visibility: hidden;.

$("#hideShow").click(function() { $("#message").toggle(); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<a href="#" id="hideShow">My Title</a>
<div id="message" style="display:none; border: 1px solid #777; width: 400px; padding: 1%;">
    Blah Blah Blah Blah
</div>
like image 83
Rikesh Avatar answered Apr 24 '26 23:04

Rikesh