jQuery removeClass 持续时间不起作用?
我有一个具有以下样式的段落:
.design_info_box p.design_info_desc
{
height:30px;
text-overflow: ellipsis;
overflow:hidden;
}
这样,您可以看到前两行文本,并带有“阅读更多”按钮,该按钮会展开段落以显示文本的其余部分。
以下是该按钮的代码:
$(".read-more div").click(function(){
$(this).parent().parent().children("p").removeClass("design_info_desc", "slow");
$(this).hide();
});
这确实删除了该类并显示了整个段落。但是,它不会动画。根据文档 removeClass 应该有一个动画持续时间。我还尝试用 10000 这样的数字替换“慢”。
它没有动画有什么原因吗?
I have a paragraph set with the following style:
.design_info_box p.design_info_desc
{
height:30px;
text-overflow: ellipsis;
overflow:hidden;
}
With this, you can see the first 2 lines of text with a button to "read more" which expands the paragraph to show the rest of the text.
Here is the code for the button:
$(".read-more div").click(function(){
$(this).parent().parent().children("p").removeClass("design_info_desc", "slow");
$(this).hide();
});
This does remove the class and the entire paragraph is revealed. However, it does not animate. According to the docs removeClass should have a duration for animation. I also tried substituting "slow" with a number like 10000.
Is there a reason why it is not animating?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不起作用的原因(我相信)是这是 jQueryUI 的一个功能,而不是核心 jQuery 库。在您的页面中包含对 jQueryUI 的引用,这应该开始起作用。
在这里查看现场演示:http://jsfiddle.net/YaSh6/
The reason this isn't working (I believe) is that this is a feature of jQueryUI, not the core jQuery library. Include a reference to jQueryUI in your page, and this should begin to work.
Check out a live demo here: http://jsfiddle.net/YaSh6/