![]() |
![]() ![]() |
![]() |
aqeel |
![]()
Post
#1
|
Group: Members Posts: 1 Joined: 12-April 22 Member No.: 28,312 ![]() |
<center>
<p></p> <button class="srd" id="btn"><b>click here to get code </b></button> <a class="button" href="" id="download"> BR260695 </a> <script> var downloadButton = document.getElementById("download"); var counter = 19000; var newElement = document.createElement("p"); newElement.innerHTML = ""; var id; downloadButton.parentNode.replaceChild(newElement, downloadButton); function startDownload() { this.style.display = 'none'; id = setInterval(function () { counter--; if (counter < 0) {newElement.parentNode.replaceChild(downloadButton,newElement); clearInterval(id); } else { newElement.innerHTML = +counter.toString() + "<b>⏱️ WAIT A Second</b>."; } }, 0); }; var clickbtn = document.getElementById("btn"); clickbtn.onclick = startDownload; </script> </center> |
Christian J |
![]()
Post
#2
|
. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 ![]() |
Works for me. What's the error?
|
coothead |
![]()
Post
#3
|
Advanced Member ![]() ![]() ![]() ![]() Group: Members Posts: 206 Joined: 12-January 23 From: chertsey, a small town 25 miles south west of london, england Member No.: 28,743 ![]() |
. Pleased to see your issue as I think I have the same problem, . I am also confused and in need of light on this same issue. . Need help. As @Christian J has already pointed out that the OP's posted code works OK, can you explain...
coothead |
pandy |
![]()
Post
#4
|
🌟Computer says no🌟 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: WDG Moderators Posts: 20,733 Joined: 9-August 06 Member No.: 6 ![]() |
He/it just posts to inject his spam link later.
|
Jason Knight |
![]()
Post
#5
|
Advanced Member ![]() ![]() ![]() ![]() Group: Members Posts: 103 Joined: 25-December 22 Member No.: 28,719 ![]() |
CODE <center> What is this, 1997? CODE <p></p> Hoping you deleted the content on purpose for posting on the forum and not just using this as a spacer, since that's not markup's job. CODE <button class="srd" id="btn"><b>click here to get code </b></button> what form is this submitting? You didn't say type="button" and the default for <button> is type="submit" Also what makes "click here to get some code" a proper name, personal title, or legal entity. Aka what <b> actually means? Don't just use <b> becuase you want the text bold, use it because it should be bold for grammatical reasons when not receivng "more emphasis" (<strong>'s job) CODE <a class="button" href="" id="download"> BR260695 </a> If that's supposed to be a button, why isn't it a button? CODE <script> var downloadButton = document.getElementById("download"); var counter = 19000; var newElement = document.createElement("p"); newElement.innerHTML = ""; You literally just created that paragraph. Thus its content is empty. CODE var id; downloadButton.parentNode.replaceChild(newElement, downloadButton); function startDownload() { this.style.display = 'none'; Why would the function "startDownload" be an Element object? Did you meant to use Event.currentTarget? CODE id = setInterval( function () { counter--; if (counter < 0) { newElement.parentNode.replaceChild(downloadButton,newElement); learInterval(id); else { I think you're missing a "{" there. CODE newElement.innerHTML = +counter.toString() + "<b>?? WAIT A Second</b>."; } }, 0); }; Which I think that closing bracket finally cropped up here. Either way you shouldn't be generating markup with innerHTML for "bold that's CSS' job" and "plaintext". Hell if you created a textnode for the counter you wouldn't even need to touch the rest of the contents inside the interval. CODE var clickbtn = document.getElementById("btn"); clickbtn.onclick = startDownload; </script> It's an element already on the DOM, use addEventListener not onclick. CODE </center> Did I mention this isn't 1997? The mix of 25 year out of date code and putting stuff together on single lines that shoudln't be is leading to a lot of errors. Worse, it makes it hard to figure out what it is you want this to even do. Could you just better explain what you want this to do? Maybe one of us could then provide modern working code... instead of ... that. |
![]() ![]() |
![]() |
Lo-Fi Version | Time is now: 28th April 2024 - 07:34 AM |