gpt4 book ai didi

jquery - CSS - 模拟 :hover effect on touchscreen devices

转载 作者:行者123 更新时间:2023-11-28 10:01:43 27 4
gpt4 key购买 nike

我做不到this code正常工作,

$(document).ready(function() {
$('.hover').bind('touchstart touchend', function(e) {
e.preventDefault();
$(this).toggleClass('hover_effect');
});

你能看看我的JSFiddle test script吗? ?

谢谢!

最佳答案

您正在将“touchstart touchend”绑定(bind)到“.hover”,但是没有具有类“hover”的元素。尝试像这样绑定(bind)到“p”:

$(document).ready(function() {
$('p').bind('touchstart touchend', function(e) {
e.preventDefault();
$(this).toggleClass('hover_effect');
});
});

或者一个比“p”更明确的选择器。

此外,您的 jsfiddle 没有加载 jQuery 库。

http://jsfiddle.net/8PxXL/

关于jquery - CSS - 模拟 :hover effect on touchscreen devices,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24706783/

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