Web
Analytics
Join the HITS Discord and leave your suggestions for this wiki, talk about your edits, or just chat with fellow Tally Hall fans!

Difference between revisions of "Template:Buttontest.js"

From Tally Hallmanac: The Ultimate Tally Hall Wiki
Jump to navigation Jump to search
(BlueYoshi 57EML created the page Template:Buttontest.js using a non-default content model "JavaScript": Testing)
 
(BlueYoshi 57EML changed the content model of the page Template:Buttontest.js from "JavaScript" to "wikitext")
Tag: content model change
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
const element = document.querySelector("body")
    let taskDone = false
 
    // function for show button
    const elementShow = () => {
      element.innerHTML = `
        <button id="done-button" style="background-color : ${!taskDone
          ? "#4dd432" : "#fd67ad"};" onclick=doneTask()>
          ${!taskDone ? "Done" : "not done yet"}
        </button>
        `
    }
    elementShow()


    // click Done button
    const doneTask = () => {
      taskDone = (taskDone ? false : true)
      elementShow()
    }

Latest revision as of 16:34, 21 June 2024

const element = document.querySelector("body")

   let taskDone = false
  
   // function for show button
   const elementShow = () => {
     element.innerHTML = `
       <button id="done-button" style="background-color : ${!taskDone 
         ? "#4dd432" : "#fd67ad"};" onclick=doneTask()>
         ${!taskDone ? "Done" : "not done yet"}
       </button>
       `
   }
   elementShow()
   // click Done button
   const doneTask = () => {
     taskDone = (taskDone ? false : true)
     elementShow()
   }