javascript - 从我的 javascript 代码更改 div 样式

标签 javascript jquery html css iframe

有人可以通过在我的代码中添加一些适合我的代码来帮助我吗 这是我需要的..

我的完整代码在这里 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/

相关文章:

javascript - Bootstrap 表搜索在加载到 CMS 时不起作用

javascript - 如何在图像悬停时影响上一张和下一张图像

javascript - 如何将 JavaScript 与 Tableau View 连接?

javascript - 使用 foreach 和 switch 循环遍历数组并在 angularjs 中返回不同的值

javascript - 在 RaphaelJS 元素中添加 HTML

jquery 排序表列

php - 通过 ajax post 将 div Html 和 Css 保存在数据库中。

javascript - 在结果后添加查看更多 Select2

需要 JavaScript、J Query 帮助,如何对跨度值求和,如下面的 HTML 所示

javascript - 复制 html 元素以缩放至全屏的正确方法