JS — getElementById not work on elements inside the document element?
1 min readAug 28, 2018
1. var x = document.getElementById('myId');
2. var y = x.getElementById('mySecondId');
second line doesn’t work!
why didn’t I think about this before?
- es5 works like below.
const x = document.querySelector('.h1');
const y = x.querySelector('.h2');