[英]jQuery Slide Toggle function not called
I am having trouble with jQuery Slide Toggle. 我在使用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) 我在页面上有一堆帖子是从数据库中提取的,它们的结构是这样的(伪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函数,但看不到问题出在哪里。
jQuery does not have a Toggle()
method. jQuery没有Toggle()
方法。
You mean slideToggle()
. 您的意思是slideToggle()
。
You're asking about jQuery "Slide Toggle" but your code is using something called .Toggle()
, which does not exist as it is spelled. 您在问有关jQuery“ Slide Toggle”的问题,但是您的代码使用的是.Toggle()
这个东西,因为它的拼写不存在。
It should be .slideToggle()
or just .toggle()
(note: the lack of capital T in the second). 它应该是.slideToggle()
或仅仅是.toggle()
(注意:第二个中缺少大写.toggle()
T)。 However, there is no sliding/animation with .toggle()
. 但是, .toggle()
没有滑动/动画。
$(this).parent().parent().children("p").Toggle(400);
Bad for performance and Toggle()
does not exist. 对性能Toggle()
,并且Toggle()
不存在。
Replace with: 用。。。来代替:
$('#post').find('p').slideToggle(400);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.