Reputation: 2486
I am having trouble with jQuery Slide Toggle.
$(document).ready(function() {
$("a").click(function() {
$(this).parent().parent().children("p").Toggle(400);
return false;
});
});
I have a bunch of posts on the page pulled from a database, and they are structured like this (pseudo HTML)
<div post>
<div float-left location/timeInfo></div>
<div float-right bandInfo><a>slideToggleLink</a></div>
<p>theToggledElement</p>
</div>
When I click the link, the jQuery function is not called, but I cannot see what the problem is.
Upvotes: 0
Views: 543
Reputation: 98738
You're asking about jQuery "Slide Toggle" but your code is using something called .Toggle()
, which does not exist as it is spelled.
It should be .slideToggle()
or just .toggle()
(note: the lack of capital T in the second). However, there is no sliding/animation with .toggle()
.
Upvotes: 1
Reputation: 94121
$(this).parent().parent().children("p").Toggle(400);
Bad for performance and Toggle()
does not exist.
Replace with:
$('#post').find('p').slideToggle(400);
Upvotes: 1