What do you want to save?
Add Code snippet
New code examples
-
Other 2021-10-20 16:08:06
click button binding after useeffect
() => { useEffect(() => { const clicked = () => console.log('window clicked') window.addEventListener('click', clicked) // return a clean-up function return () => { window.addEventListener('click', function() { ... Add solution -
Javascript 2021-10-17 22:50:04
js on page loaded
//two ways of executing JS code after page is loaded, use "DOMContentLoaded" when able document.addEventListener("DOMContentLoaded", function(){ //dom is fully loaded, but maybe waiting on images & css files }); window.... Add solution -
Javascript 2021-10-17 19:22:03
react responsive screen size
const MyComponent = () => { // Declare a new state variable with the "useState" Hook const [width, setWidth] = React.useState(window.innerWidth); const breakpoint = 620; React.useEffect(() => { /* Inside of a "useEffect&q... Add solution -
Javascript 2021-10-15 05:12:08
play background music in jasvascript
<audio src="https://www.bensound.com/bensound-music/bensound-moose.mp3"></audio> <Script> window.addEventListener("DOMContentLoaded", event => { const audio = document.querySelector("audio"); a... Add solution
Best helpers
Ranking is empty