我从小提琴复制代码和Dreamweaver也没有响应javascript

时间:2015-01-17 16:01:20

标签: javascript html css

我试图使用刚刚在小提琴上共享的代码,当在Dreamweaver上尝试它时,它也没有用。我希望将代码用于我的最终项目。我最近做了研究,这个代码看起来比另一个简单。在js,css和html中还是新的。

var downloadButton = document.getElementById("download");
var counter = 10;
var newElement = document.createElement("p");
newElement.innerHTML = "You can download the file in 10 seconds.";
var id;

downloadButton.parentNode.replaceChild(newElement, downloadButton);

id = setInterval(function () {
    counter--;
    if (counter < 0) {
        newElement.parentNode.replaceChild(downloadButton, newElement);
        clearInterval(id);
    } else {
        newElement.innerHTML = "You can download the file in " + counter.toString() + " seconds.";
    }
}, 1000);
.button {
    background-color: #ddcccc;
    border: 1px solid black;
    color: black;
    font-family: Arial;
    font-size: small;
    text-decoration: none;
    padding: 3px;
}
<script src="b.js"></script>
<link rel="stylesheet" href="c.css" />

<a href="downloadFile.zip" id="download" class="button">Download the file...</a>

0 个答案:

没有答案