同一页面中有多个购物车按钮 [英] More than one cart button in the same page

查看:164
本文介绍了同一页面中有多个购物车按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个购物网站。我正在设计这种方式,我在同一页面上有超过1件产品的数量和加入购物车按钮。数量是预先加载1值的下拉列表。因此,当我点击添加到购物车按钮时,该页面中的所有产品都会添加到购物车中。如何评估这个?附上页面外观样图。

I am designing a shopping site. I am designing in such a way, I have more than 1 product with quantity and "add to cart" button in the same page. The quantity is a dropdown with "1" value preloaded.so when i click "add to cart" button, all the products in that page get added to cart. How to evaluate this? Attached the sample picture of how the page will look like.

我没有任何示例代码可以在这里分享。我想知道这是如何实现的。

I don't have any sample code to share here. I would like to know how this can be implemented.

推荐答案

您可以很好地使用 $ (this)选择器。

You can make good use of the $(this) selector.

以下是我将如何使用 $(this)选择器确保一次只添加一个项目。

Here's an example of how I would use the $(this) selector to make sure only one item was added at a time.

https://jsfiddle.net/8y82zq29/

这篇关于同一页面中有多个购物车按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆