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.
jQuery does not have a Toggle()
method.
You mean slideToggle()
.
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()
.
$(this).parent().parent().children("p").Toggle(400);
Bad for performance and Toggle()
does not exist.
Replace with:
$('#post').find('p').slideToggle(400);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.