Queryselectorall Didn't Working But Queryselector Did
Making simple extension for chrome. Second function didn't work when changing 'querySelector' into 'querySelectorAll'. var ele2 = document.querySelectorAll('.view-count '); wi
Solution 1:
querySelectorAll
returns a collection of nodes as opposed to querySelector
which returns a single node.
To get to a node in the collection you'll have to reference it via an index.
ele2[0].innerHTML = ele2[0].innerHTML.trim();
Solution 2:
querySelector returns first query based of parameter value. querySelectorAll returns list in array-like structure. To fetch individual element inside list, use index. Exp,
ele2[0]// first iterationele2[1]// second iteration
Post a Comment for "Queryselectorall Didn't Working But Queryselector Did"