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');
}
Look 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.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>
try:
$(document).ready(function(){
$('.togglePlay').trigger('click');
});
Assuming the loading page has a div containing data-role=page
and its id
is mypage
, you could use the pageinit
event to fire up the click
on '.togglePlay'
like this :
$(document).on("pageinit", "#mypage", function () {
$('.togglePlay').trigger('click');
});
References
ready
event with jQM, see jQuery Mobile: document ready vs page events I use jQuery tap() method.
$('.togglePlay').tap();
http://api.jquerymobile.com/tap/
This works for me :)
you should be able to set autoplay=true or some other setting with...
<video controls autoplay>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
example from: http://www.w3schools.com/tags/att_video_autoplay.asp
without the use of js