)
}
}
)
(
}
{
)
)
(
)
(
(
{
}
)
(
)
}
)
)
{
(
(
)
)
}
)
(
}

Confirm Background Color

  1. const btn = document.body.appendChild(
  2.   document.createElement('button')
  3. )
  4. btn.innerHTML = 'click me'
  5. btn.style.fontSize = '2em'
  6. btn.style.cursor = 'pointer'
  7. btn.addEventListener('click', e => {
  8.   if (confirm('Do you want to change the background color?')) {
  9.     const deg = Math.random() * 360
  10.     document.body.style.backgroundColor = `hsl(${deg}deg, 50%, 50%)`
  11.   }
  12. })

Change background color with a call to confirm

// javascript // ui
snippet.zone ~ 2021-24 /// {s/z}