Div在移动设备上不会消失onclick事件?
问题描述:
当我点击我的桌面上的playbutton/div它消除了div videotekst
,但是当我点击我的手机div div videotekst
不会消失。Div在移动设备上不会消失onclick事件?
这里是我的代码我使用:
<div class="overInreach"> <video id="my-video" class="video-js" controls preload="auto" width="100%" height="427px"
poster="MY_VIDEO_POSTER.jpg" data-setup="{}" onended="videoEnded()">
<source src="<?php echo get_template_directory_uri(); ?>/images/Inreach_Promo_v2.mp4" type='video/mp4'>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
<script src="http://vjs.zencdn.net/5.8.8/video.js"></script> <script>
$(document).ready(function()
{
$(".vjs-big-play-button").click(function()
{
$("#videotekst").css("z-index", "-1");
$(".vjs-big-play-button").css("display", "none !important");
$(".vjs-control-bar").css("display", "flex !important");
});
$(".vjs-poster").click(function()
{
$("#videotekst").css("z-index", "-1");
$(".vjs-big-play-button").css("display", "none !important");
$(".vjs-control-bar").css("display", "flex !important");
});
});
</script>
<script>
function videoEnded() {
$("#videotekst").css("z-index", "1");
$(".vjs-big-play-button").css("display", "block");
$(".vjs-control-bar").css("display", "none");
}
</script>
答
因为,在手机没有单击事件。有touchStart和touchEnd事件有:
所以可以尝试这样的:
var clickHandler = ('touchend' in document.documentElement ? "touchend" : "click");
$(".vjs-big-play-button").bind(clickHandler, function(e) {
alert("clicked or tapped. This button used: " + clickHandler);
});
+1
请评论downvoters –
+1
@downvoters,如果您有任何疑问,请检查其他帖子上接受的其他答案与相同的问题.. http://*.com/questions/25873639/jquery-onclick-not-working-on-移动 –
你为什么不尝试$( “VJS-大播放” 按钮)隐藏(); – rahulsm