Kelvin Ricafort
Kelvin Ricafort

Reputation: 3

how to count items in todolist app in javascript

Hi how to update the count of to do items

<span>Item count: <span id="item-count">0</span></span>

function updateCount() {
const count = list.childElementCount;

}

Upvotes: 0

Views: 277

Answers (2)

Krishan Kumar
Krishan Kumar

Reputation: 403

$('#main-div .specific-class').length

source: How can I count the number of elements with same class?

Upvotes: 0

imvain2
imvain2

Reputation: 15847

You can use innerHTML, innerText or textContent;

var counter = document.querySelector("#item-count");    
counter.innerHTML = 0;

or

var counter = document.querySelector("#item-count");
counter.innerText = 0;

or

var counter = document.querySelector("#item-count");
counter.textContent = 0;

Upvotes: 1

Related Questions