H
H
Httdientee2021-07-10 14:19:14
JavaScript
Httdientee, 2021-07-10 14:19:14

Summing up all active buttons?

How to get all buttons with the active class in jquery and sum them up by getting the value from data-cost?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-07-10
@Httdientee

$('button.active').get().reduce((acc, n) => acc + +n.dataset.cost, 0)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question