我需要tap在一些选择器上设置触发器。我正在使用 jQuery Mobile 和这个功能,那么有什么不对吗?
window.onload = load;
function load() {
  $('.togglePlay').trigger('tap');
}
    我需要tap在一些选择器上设置触发器。我正在使用 jQuery Mobile 和这个功能,那么有什么不对吗?
window.onload = load;
function load() {
  $('.togglePlay').trigger('tap');
}
    // 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>
尝试:
$(document).ready(function(){
    $('.togglePlay').trigger('click');
});
    假设加载页面有一个包含它的 divdata-role=page并且它id是mypage,您可以使用该pageinit事件来启动clickon ,'.togglePlay'如下所示:
$(document).on("pageinit", "#mypage", function () {
  $('.togglePlay').trigger('click');
});
参考
ready在 jQM 中使用事件的原因,请参阅jQuery Mobile:文档就绪与页面事件 您应该能够设置 autoplay=true 或其他一些设置...
<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> 
示例来自:http ://www.w3schools.com/tags/att_video_autoplay.asp
不使用js