L
L
ligisayan2015-06-29 11:35:52
JavaScript
ligisayan, 2015-06-29 11:35:52

I can’t overwrite the number of elements - where did I make a mistake?

Greetings. There is an example in fiddle , which shows a product section, in which you can increase / decrease the number of products. I can't find a match in .cart_list li and overwrite their quantity if the product names are the same, and also so that the sum of all products is redefined depending on the change in the number of elements.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kir ---, 2015-06-29
@SowingSadness

The match must be searched for by a unique identifier, which is best stored somewhere in the data-attributes, for example data-id.

<li data-id="123">
   <div class="product-name">Товар 3</div>
   <span class="quantity">2 × <span class="amount">1.440.000 руб</span></span>
</li>

$('[data-id="%id%"]'.replace("%id%", 123))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question