html pasrser js code example

Example 1: html parser javascript

var parser = new DOMParser();
var htmlDoc = parser.parseFromString(txt, 'text/html');
htmlDoc.getElementById("someID");

Example 2: resize js

window.addEventListener('resize', function(event){
  // do stuff here
});

Example 3: resize js

const heightOutput = document.querySelector('#height');
const widthOutput = document.querySelector('#width');

function reportWindowSize() {
  heightOutput.textContent = window.innerHeight;
  widthOutput.textContent = window.innerWidth;
}

window.onresize = reportWindowSize;