JQuery悬停意图:将“悬停时”转换为到“点击时”
- 我正在使用 Hoverintent JQuery 插件来扩展 DIV。
- 现在我希望它“点击”而不是“悬停”工作,
我该怎么做?我知道这是简单的 JQuery,但我的知识缺乏。任何帮助将不胜感激。这是代码:
$(document).ready(function(){
//Expand Div
$("#expandbutton").click({
over: ExpandDiv,
timeout: 100,
out: DoNothing
});
});
function ExpandDiv(){
$("#expander").animate({"height":200},400, "easeOutSine");
$("#expandbutton").css({opacity: 0.0, visibility: "hidden"}).animate({opacity: 0.0});
}
- I'm using the Hoverintent JQuery plugin to make a DIV expand.
- Now I want it to work "on click" rather than "on hover"
How do I do this? I know this is simple simple JQuery, but my knowledge is lacking. Any help would be much appreciated. Here is the code:
$(document).ready(function(){
//Expand Div
$("#expandbutton").click({
over: ExpandDiv,
timeout: 100,
out: DoNothing
});
});
function ExpandDiv(){
$("#expander").animate({"height":200},400, "easeOutSine");
$("#expandbutton").css({opacity: 0.0, visibility: "hidden"}).animate({opacity: 0.0});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要简单地在单击时执行
ExpandDiv
方法,您可以使用 jQuery 的.click()
,如下所示:To simply execute that
ExpandDiv
method on click, you can use jQuery's.click()
like this:将参数传递给
click()
后直接调用该函数Call the function directly after passing your parameters to the
click()