gpt4 book ai didi

javascript - 如何使用 jQuery 触发点击事件

转载 作者:搜寻专家 更新时间:2023-11-01 04:43:38 25 4
gpt4 key购买 nike

我需要在某些选择器上设置 tap 触发器。我正在使用 jQuery Mobile 和这个函数,有什么不对吗?

window.onload = load;

function load() {
$('.togglePlay').trigger('tap');
}

最佳答案

查看taptaphold触摸事件。

// The tap event won't be emitted along with the taphold event
$.event.special.tap.emitTapOnTaphold = false;

$("#fire").on("taphold", function() {
$(this).addClass("colorize");
});
$("#banana").on("tap", function() {
$(this).hide();
});
body {
text-align: center;
}

span {
font-size: 3rem;
}

span:hover {
cursor: pointer;
}

.colorize {
color: transparent;
text-shadow: 0 0 0 red;
}
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

<h3>If you tap and hold me for 750 milliseconds, I will fill up with color.</h3>
<span id="fire">🔥🔥🔥</span>
<hr />
<h3>If you tap me quick, I will dispear.</h3>
<span id="banana">🍌🍌🍌</span>

关于javascript - 如何使用 jQuery 触发点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17270568/

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