Ошибка: Uncaught TypeError: Cannot read property 'classList' of null. Как исправить?

Выдает ошибку, что элемент <body> не найден. Где может быть косяк?

let isMobile = {
    Android: function () {return navigator.userAgent.match(/Android/i);},
    BlackBerry: function () {return navigator.userAgent.match(/BlackBerry/i);},
    IOS: function () {return navigator.userAgent.match(/IPhone|IPad|IPod/i);},
    Opera: function () {return navigator.userAgent.match(/Opera Mini/i);},
    Windows: function () {return navigator.userAgent.match(/IEMobile/i);},
    any: function () {return (isMobile.Android()|| isMobile.BlackBerry()|| isMobile.IOS()|| isMobile.Opera()|| isMobile.Windows());}};

let body=document.querySelector ('body');
    if (isMobile.any()){
    body.classList.add ('touch');
} else {
    body.classList.add ('pc');
}

Ответы (0 шт):