Answer the question
In order to leave comments, you need to log in
Why is the dom element not found by parameter from the array?
Good afternoon, I am writing an extension for chrome.
And everything works fine, except for one function.
content-script.js:
chrome.storage.local.get(['keys'], function(check){
mass = check.keys;
//mass = ['2443330','7579444','9581333','2609336','8612108','1617782','2600085'];
var index;
for(index = 0; index < mass.length; ++index){
//console.log(mass[index]);
let urlx = document.querySelectorAll('a[href$="'+mass[index]+'"]');//должна выбираться ссылка с атрибутом href заканчивающаяся на цифру из массива.
console.log(urlx);
for(var i = 0; i < urlx.length; i++) {
var tb_str = urlx[i].parentElement.previousSibling;
var tr_str = urlx[i].parentElement.parentElement;
var chislo = tb_str.innerHTML; //92600863
tr_str.querySelector('a[name="table_checkbox_'+chislo+'"]').checked = true;
}
}
});
let urlx = document.querySelectorAll('a[href$="'+mass[index]+'"]');
and, accordingly, all further manipulations on the found objects. I see this in the console [ ]
, but why don't I understand? Answer the question
In order to leave comments, you need to log in
because it's check.keys
already an array? and you put an array in an array mass = [check.keys]
?
trymass = check.keys
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question