Home
Forums
New posts
Search forums
What's new
New posts
Latest activity
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
All Topics
Technology
Реализация счетчика на каждом товаре
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Иван" data-source="post: 739948"><p>[CODE]function renderElements() {</p><p> const fruitsList = document.getElementById("list");</p><p> fruits.forEach((item) => {</p><p> const child = document.createElement("div");</p><p> child.innerHTML += `</p><p> <div class="main__list-item" id=${item.id}></p><p> <div class="item__img"></p><p> <img src=${item.img} alt="" /></p><p> </div></p><p> <div class="item__text1">${item.name}</div></p><p> <div class="item__text2">${item.description}</div></p><p> <div class="item__price">${item.price} руб.</div</p><p> <<div class="item__btn"></p><p> <button class="item__btn-add" id="add-${item.id}">+</button></p><p> <button class="item__btn-delete" id="delete-${item.id}">-</button></p><p> <div class="fruits__count" id="count-${item.id}">0</div></p><p> </div></p><p> </div>`;</p><p> fruitsList.appendChild(child);</p><p> });</p><p>}</p><p>renderElements();</p><p>[/CODE]</p><p></p><p>Есть вот такой код, рендерит карточки товаров. Но как мне реализовать счетчик на каждую кнопку + и - ?</p></blockquote><p></p>
[QUOTE="Иван, post: 739948"] [CODE]function renderElements() { const fruitsList = document.getElementById("list"); fruits.forEach((item) => { const child = document.createElement("div"); child.innerHTML += ` <div class="main__list-item" id=${item.id}> <div class="item__img"> <img src=${item.img} alt="" /> </div> <div class="item__text1">${item.name}</div> <div class="item__text2">${item.description}</div> <div class="item__price">${item.price} руб.</div <<div class="item__btn"> <button class="item__btn-add" id="add-${item.id}">+</button> <button class="item__btn-delete" id="delete-${item.id}">-</button> <div class="fruits__count" id="count-${item.id}">0</div> </div> </div>`; fruitsList.appendChild(child); }); } renderElements(); [/CODE] Есть вот такой код, рендерит карточки товаров. Но как мне реализовать счетчик на каждую кнопку + и - ? [/QUOTE]
Name
Verification
Post reply
Home
Forums
All Topics
Technology
Реализация счетчика на каждом товаре
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top