I need help converting this JavaScript embedded in HTML code into a standalone JavaScript file. I am creating a toggle switch that, when clicked, should go to a new page after the transformation. I am looking for the non-embedded version of the function. Here is the code snippet:
<div class="statement">Slide to Play!</div>
<div class="container">
<div class="play" onclick= "this.classId.toggle('active')">
<div class="inner-square"></div>
</div></div>
This is the JavaScript code that I have tried but it's not working:
const transition = document.querySelector('play');
Promise.all(
document.getElementById("play").onclick = function() {
transition.addEventListener('transitionend', () => {
console.log('Transition ended');
location.assign("gamepage.html")
}
);
Promise.all(
})
).then(transition.addEventListener('transitionend', () => {
console.log('Transition ended');location.assign("gamepage.html")});