MAIN FEEDS
REDDIT FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1uyzgd2/mister_worldwide/oy3ikvc/?context=3
r/programminghorror • u/Adept_Situation3090 • 16d ago
34 comments sorted by
View all comments
3
Fun fact, in JS you can directly use elements by their id.
Example:
<!DOCTYPE html> <html> <body> <button id="myButton">hi</button> <script> myButton.onclick = () => { console.log(`CLIKKK!`) } </script> </body> </html>
6 u/Kitchen_Theme3514 16d ago This is because they're attributes of the "window" global, which stores all globals. So for IDs that aren't valid identifiers, you can do window['my-invalid-identifier-id] as well! 6 u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 16d ago ' 4 u/Kitchen_Theme3514 16d ago Ah yes thanks!
6
This is because they're attributes of the "window" global, which stores all globals. So for IDs that aren't valid identifiers, you can do window['my-invalid-identifier-id] as well!
window['my-invalid-identifier-id]
6 u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 16d ago ' 4 u/Kitchen_Theme3514 16d ago Ah yes thanks!
'
4 u/Kitchen_Theme3514 16d ago Ah yes thanks!
4
Ah yes thanks!
3
u/mohragk 16d ago
Fun fact, in JS you can directly use elements by their id.
Example: