Как исправить ошибку JS Uncaught TypeError: Cannot read property 'getElementsByTagName' of null
?
jQuery(document).ready(function($) {
const select2 = document.querySelector('#cf_wrapper_inner_custom_f_7_132').getElementsByTagName('option');
for (let i = 0; i < select2.length; i++) {
if (select2[i].textContent === 'Text1') select2[i].selected = true;
}
const select = document.querySelector('#cf_wrapper_inner_custom_f_4_132').getElementsByTagName('option');
for (let i = 0; i < select.length; i++) {
if (select[i].textContent === 'Text2;') select[i].selected = true;
}
const select1 = document.querySelector('#cf_wrapper_inner_custom_f_6_132').getElementsByTagName('option');
for (let i = 0; i < select1.length; i++) {
if (select1[i].textContent === 'Text3') select1[i].selected = true;
}
});