alex_01573 February 2016

Using .toggle() causes problems

I'm trying to make a show/hide button and I can't manage to get it working. What I want to do is when the user clicks the button, some content will appear. Also, it has to be possible to hide the content if the show/hide button is pressed again.

I came up wiith this:

<script>
$(document).ready(function(){
    $("hideshow").click(function(){
        $("content1").toggle('slow');
    });
});
</script>
<center><input type='button' id='hideshow' class='myButton' value='Show/Hide'></center>

<div id="content1" style="display: none;">
<!-- some content -->
</div>

I read it over and over again, but I still can't figure it out. What did I do wrong?

Answers


Fri Day February 2016

You didn't use the id.

you just did ("hideshow") and ("content1") instead of ("#hideshow") and ("#content1")

if you do ("p") it doesn't to the id "p" it does

 <p>

but if you do ("hideshow"), it does

<hideshow>

that doesn't exist

Post Status

Asked in February 2016
Viewed 2,709 times
Voted 10
Answered 1 times

Search




Leave an answer