I need to set tap
trigger on some selectors. I'm using jQuery Mobile and this function, so what is not right?
window.onload = load;
function load() {
$('.togglePlay').trigger('tap');
}
I need to set tap
trigger on some selectors. I'm using jQuery Mobile and this function, so what is not right?
window.onload = load;
function load() {
$('.togglePlay').trigger('tap');
}
Share
Improve this question
edited Jun 24, 2013 at 9:16
Omar
31.7k9 gold badges72 silver badges116 bronze badges
asked Jun 24, 2013 at 7:58
LukasLukas
7,74420 gold badges79 silver badges127 bronze badges
10
- Maybe you should use $.ready function instead of window's onload event – Pavel Gruba Commented Jun 24, 2013 at 8:03
- $(document).ready(function(){ – suhailvs Commented Jun 24, 2013 at 8:04
- What do you want to achieve exactly? – Omar Commented Jun 24, 2013 at 9:15
- i need to automaticly fireup some video on ipad... so i'm trying to simulate pla ybutton click – Lukas Commented Jun 24, 2013 at 9:20
- 1 @user10089632 sory man but i don't remember this case, this was at 2013 :) also haven't used jQuery since more then year now – Lukas Commented Aug 22, 2017 at 23:27
5 Answers
Reset to default 1Look into tap and taphold touch event.
// 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./mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery./jquery-1.11.1.min.js"></script>
<script src="http://code.jquery./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">