Answers for "listen to document height changes"

0

listen to document height changes

// create an Observer instance
const resizeObserver = new ResizeObserver(entries => 
  console.log('Body height changed:', entries[0].target.clientHeight)
)

// start observing a DOM node
resizeObserver.observe(document.body)

// click anywhere to rnadomize height
window.addEventListener('click', () =>
  document.body.style.height = Math.floor((Math.random() * 5000) + 1) + 'px'
)
Posted by: Guest on November-27-2020

Code answers related to "listen to document height changes"

Code answers related to "Javascript"

Browse Popular Code Answers by Language