有人为我创建了这段代码:http: //jsfiddle.net/kzFWa/
var downloadButton = document.getElementById("continue");
var counter = 60;
var newElement = document.createElement("p");
newElement.innerHTML = "<h3>or click here to continue in 60 seconds</h3>";
var id;
downloadButton.parentNode.replaceChild(newElement, downloadButton);
id = setInterval(function() {
counter--;
if(counter < 0) {
newElement.parentNode.replaceChild(downloadButton, newElement);
//newElement.innerHTML = "<a href="survey.php">Click Me To Continue</a>"
clearInterval(id);
} else {
newElement.innerHTML = "<h3>or click here to continue in " + counter.toString() + " seconds.</h3>";
}
}, 1000);
但是,如果我改变
newElement.parentNode.replaceChild(downloadButton, newElement);
至
newElement.innerHTML = "<a href="survey.php">Click Me To Continue</a>"
代码将不再运行。我究竟做错了什么?