How to hide and show divs?

How to hide and show divs?

I am trying to create two divs, one main div and another sub div. Main div there will be a button upon clicking that button sub div should be shown.

I am using the following code but getting error....

<h1>
Show/Hide using jQuery</h1>
<a id="showhidetrigger" href="#">show/hide</a>
<div id="showhidetarget">
This is the box that is hidden and shown.
</div>

<script type="text/javascript">
$(document).ready(function () {
$('#showhidetarget').hide();

$('a#showhidetrigger').click(function () {
$('#showhidetarget').toggle(400);
});
});
</script>









Web Designing Company