[英]Hiding a #div after click / play
This is what I'm trying; 这就是我正在尝试的;
$(document).ready(function(){
//Slides object with a time (integer) and a html string
var slides = {
0: '<div id="playdiv" onclick="vidplay()"><img src="imgs/poster1.png" style="min-height: 300px;"/></div>',
How Can I keep the functionality of the video playing; 如何保持视频播放功能; onClick but also have the #div with the image inside of it; onClick,但其中也包含#div及其图像; disappear after click. 单击后消失。
function vidplay() {
var video = document.getElementById("video");
var button = document.getElementById("play");
if (video.paused) {
video.play();
(playdiv).style.display="none";
Library in reference: http://cuepoint.org/ 参考图书馆: http : //cuepoint.org/
SO. 所以。 What you guys are saying; 你们在说什么 is this, huh? 是这个吗?
function vidplay() {
var video = document.getElementById("video");
var button = document.getElementById("play");
if (video.paused) {
video.play();
$("#playdiv").hide();
But this doesn't work. 但这是行不通的。 Instead it just stops all functionality; 相反,它只是停止了所有功能。 and the video is frozen on first frame. 并且视频在第一帧被冻结。
Second fix attempt. 第二次修复尝试。
0: '<div id="playdiv" onclick="vidplay()"><img id="supercoolimg" src="imgs/poster1.png" style="min-height: 300px;"/></div>',
function vidplay() {
var video = document.getElementById("video");
var button = document.getElementById("play");
if (video.paused) {
video.play();
document.getElementById('supercoolimg').style.display='none';
Fail log. 失败日志。 11:59AM. 上午11:59。 11 degrees. 11度。 NYC. 纽约市。 (Not doing this outside, but still.) (不要在外面这样做,但仍然这样做。)
Below is my FULL code pasted within pastebin . 下面是我粘贴在pastebin中的完整代码。
Can anyone advise what I'm doing wrong here? 有人可以告诉我我在做什么错吗? Still nothing. 依然没有。
http://pastebin.com/MYJk5gv1 http://pastebin.com/MYJk5gv1
Most recent (fail) attempt; 最近(失败)尝试;
$(playdiv).find('img').css("display","none");
This should do it. 这应该做。
function vidplay() {
var video = document.getElementById("video");
var button = document.getElementById("play");
if (video.paused) {
video.play();
$("#playdiv").find('img').css("display","none");
...
在img中添加一个id
document.getElementById('idoftheimg').style.display='none';
你可以这样使用;)
$("#playdiv").hide();
Using JQuery (I assume that pause
property and play
function exists) 使用JQuery(我假设存在pause
属性和play
函数)
Remove onclick="vidplay()"
declaration and define click
event like this : 删除onclick="vidplay()"
声明并定义click
事件,如下所示:
$('#playdiv').click(function(){
var $video = $("#video");
if ($video.paused) {
$video.play();
//Hide the div
$(this).fadeOut(300);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.