有人可以通过在我的代码中添加一些适合我的代码来帮助我吗 这是我需要的..
我的完整代码在这里 http://jsfiddle.net/2urmku1h/
这里我需要改变
<div style="display:none;">Change style of this div to Block fro js above</div>
这是我在 head 部分的一些 js 代码,我需要它一些如何工作
function startChecking() {
secondsleft -= 1e3;
document.querySelector(".load_video").innerHTML = "Please Wait.. " + Math.abs(secondsleft / 1e3) + " Seconds";
if (secondsleft == 0) {
clearInterval(interval);
document.querySelector(".load_video").style.display = "none";
document.querySelector(".frame_src").style.display = "";
document.querySelector(".frame_src").src = document.querySelector(".frame_src").getAttribute("data-src")
}
}
function startschedule() {
clearInterval(interval);
secondsleft = threshold;
document.querySelector(".load_video").innerHTML = "Please Wait.. " + Math.abs(secondsleft / 1e3) + " Seconds";
interval = setInterval(function() {
startChecking()
}, 1e3)
}
function resetTimer() {
startschedule()
}
var timeout, interval;
var threshold = 1e4;
var secondsleft = threshold;
window.onload = function() {
startschedule()
}
我需要的是,如果我点击其中一个视频链接,无论还剩 5 秒还是什么,它都会停止倒计时,它会停止倒计时并隐藏此 div <div class="load_video"></div>
并显示 iframe。但我想要它,当我单击其中一个按钮时,它确实隐藏了 load_video div 并显示了 iframe,但我也希望它改变此 div 的样式 <div style="display:none;">Change style of this div to Block fro js above</div>
显示阻止。
希望大家明白
最佳答案
您可以通过多种方式选择要引用的 div 元素。为简单起见,假设您向 div 添加一个 id...
<div id="modifyMe" style="display:none;">Change style of this div to Block fro js above</div>
...然后在您希望将 div 更改为显示 block 的位置添加以下代码。
jQuery 解决方案:
$('#modifyMe').show();
没有 jQuery:
document.getElementById('modifyMe').style.display = 'block';
关于javascript - 从我的 javascript 代码更改 div 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32960988/