gpt4 book ai didi

javascript - 如何更改悬停以单击 jquery slider

转载 作者:行者123 更新时间:2023-11-30 13:12:06 29 4
gpt4 key购买 nike

我正在使用以下代码(我在别处找到并试图修改以满足我的需要)创建一个从右侧滑到我的屏幕上的 div。当我单击而不是悬停时,我将如何让它滑出?提前感谢您的帮助。

jQuery(function($) {
$(document).ready(function() {
$('#introbutton').hover(function() {
$('#intro-container').stop(true, false).animate({
'left': '0px'
}, 900);
}, function() {
jQuery.noConflict();
});

jQuery('#introbutton').hover(function() {
// Do nothing
}, function() {

jQuery.noConflict();
jQuery('#intro-container').animate({
left: '100%'
}, 800);

});
});
});

最佳答案

尝试使用 on.() 即

$('#introbutton').on('click', function() {
// do whatever here
});

编辑

$('#introbutton').on('click',function(){
$('#intro-container').stop(true, false).animate({'left': '0px'}, 900);
});

您也可以按照 TheSmose 使用 click 作为 on() 的“快捷方式”- 但请记住

.on() is the recommended way to do all your event binding as of jQuery 1.7. It rolls all the functionality of both .bind() and .live() into one function that alters behavior as you pass it different parameters.

关于javascript - 如何更改悬停以单击 jquery slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13518061/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com