A
A
AskJs2018-02-24 14:25:16
JavaScript
AskJs, 2018-02-24 14:25:16

How to add multiple div numbers?

Hello.
Such question:
I have ul > li > p, div
How to find the sum of numbers in div?
PS I will introduce new divs from input (now this is not so important).

5a914b7a5a334715227731.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shad30, 2018-02-24
@AskJs

$(function(){
var sumDiv = 0;
$('li div').each(function(){
var html = $(this).text() ;
sumDiv += Number(html);
});
console. log(sumDiv);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question