Where is the error in the code here?
-
div.onclick = function() { div.classList.toggle('complete'); var allComplete = document.querySelectorAll('complete'); if(allComplete.length > 0){ countingEl.innerHTML = '<div class="section-count" id="counting">Выбранно:'+allComplete.length+'</div>' console.log(allComplete.length); } else{ countingEl.innerHTML = '<div class="section-count" id="counting"></div>' console.log(allComplete.length); } };
JavaScript Anonymous, Sep 19, 2019 -
document.querySelectorAll ('complete')
There should be one more point here. Or querySelectorAll should give way to getElementsByClassName.Anonymous -
In document.querySelectorAll you are looking for a tag called "complete" and not a tag with class "complete", add a period before completeAnonymous
-
You are looking for the "COMPLETE" tag in
document.querySelectorAll
, but you need a tag with the ".COMPLETE" class.
here is the code without error:var allComplete = document.querySelectorAll('.complete');
Anonymous
3 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!