I want to create a JS function to capture the 'value' attributes on each li element within the 'completed-tasks' unordered list. I also want it to add these values together.
My html:
<ul id="completed-tasks">
<li value="1"><label>item 1</label></li>
<li value="2"><label>item 2</label></li>
<li value="3"><label>item 3</label></li>
</ul>
My javascript function:
var totalValue = function(){
//cycle over ul items
for (var i=0; i<completedTasksHolder.children.length; i++){
//I want to capture 'value' of each li here
}
//I want to add values here
}
Please help me finish that function ^^ (I know the loop is working). totalValue should be 6.