Why I can't use addEventListener method | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
15th May 2023, 6:48 AM
MĆ„x ĆœĆ±Å„ÄÆ
2 Respostas
+ 9
You can, just wrap your JS code tab in a window.onload function.
15th May 2023, 6:50 AM
Ausgrindtube
Ausgrindtube - avatar
0
MĆ„x ĆœĆ±Å„ÄÆ you can try the <dialog> element. html tab: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <button class="bt">menu</button> <dialog id="d1">gsbsjxksns</dialog> </body> </html> javascript tab: window.onload = () => { const bt = document.querySelector('.bt'); const d1 = document.querySelector('#d1'); let toggle = false; bt.onclick = () => { toggle = !toggle; toggle ? d1.show(): d1.close(); } }
16th May 2023, 7:26 AM
Bob_Li
Bob_Li - avatar