【发布时间】:2016-11-23 19:48:22
【问题描述】:
我想将选定的 ID(使用 Guids)存储到稍后用于结帐的 cookie 中。如何在不覆盖旧值的情况下将新值存储到 cookie 中?
<script type="text/javascript">
$(document).ready(function () {
$('.AddProduct').click(function () {
//add following: $(this).data('id'), this is how far I got:
//$.cookie("AddedProductId", $(this).data('id'));
});
});
</script>
$(this).data('id') 从 foreach 循环中获取选定的产品 ID:
<button class="AddProduct" data-ID="@item.ID">Add to Cart</button>
【问题讨论】:
标签: jquery asp.net-mvc cookies