Unable to get property 'queryselectorall' of undefined or null reference

1

I am getting below mentioned error in my jQuery function:

var timer = document.getElementById(id);
var pdays = timer.querySelector('.days');
var phours = timer.querySelector('.hours');
var pminutes = timer.querySelector('.minutes');
var pseconds = timer.querySelector('.seconds');

0x800a138f - JavaScript runtime error: Unable to get property 'querySelector' of undefined or null reference

Please suggest to me where I can find jQuery file for .queryselectorall() method or remove above mentioned error in jQuery code ?

javascript
jquery
dom-events
asked on Stack Overflow Aug 30, 2016 by M.Y.Mnu • edited Jan 17, 2021 by Brian Tompsett - 汤莱恩

1 Answer

2

here is a suggestion! maybe your JavaScript is executing before your page loads so your document.querySelectorAll() code is returning data with undefined or null reference (zero length).

try to wrap with onload()

onload = yourFunction(){
document.querySelectorAll()
}
answered on Stack Overflow Aug 30, 2016 by Simo

User contributions licensed under CC BY-SA 3.0