I'm using this very simple jQuery code:
$("h3").click(function(){
$(this).next("table").slideToggle("slow");
});
The outcome itself actually works and the table does appear/disappear on click, but there is no effect of "slide" whatsoever - i've tried without "slow" and with "slow" - same result!?
Its almost like i'm just using .toggle()...
I cant see what could be wrong apart from the size of the table, which is only max, 12 rows.
Any ideas?
slideToggle wasn't working because the table is not a block element. In the following update I've made it a block element (instead of display:none), and then hidden it on page load with jQuery... Nice. Probably a better fix than mine.
jQuery slideToggle() Method The slideToggle() method toggles between slideUp() and slideDown() for the selected elements. This method checks the selected elements for visibility. slideDown() is run if an element is hidden. slideUp() is run if an element is visible - This creates a toggle effect.
The . slideToggle() method animates the height of the matched elements. This causes lower parts of the page to slide up or down, appearing to reveal or conceal the items. If the element is initially displayed, it will be hidden; if hidden, it will be shown.
I don't think slideToggle works on all elements... Table could be one of them... Can you place the table inside a div and run the slideToggle on the div??
Try this...
<h3>click</h3>
<div>
<table>
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
<tr>
<td>3</td>
</tr>
</table>
</div>
and
$("h3").click(function(){
$(this).next("div").slideToggle("slow");
});
Working example shown here... http://jsfiddle.net/68mcY/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With