【发布时间】:2015-02-21 19:16:21
【问题描述】:
我在使用 jPayPalCart.js 切换 myCart div 时遇到了困难。我的购物车运行良好。当我加载页面时,我可以通过单击右上角的购物车来切换购物车。我在 myCart 代码中添加了另一个按钮,显示“关闭”并关闭 myCart div。
但是,当我将商品添加到购物车时,(只有演示页面上的第一项实际添加了商品)单击购物车图标时不再触发此功能。我在浏览器的控制台中没有看到任何错误。
它仅在页面刷新时再次起作用。我怎样才能做到不用刷新页面?
非常感谢有人帮我解决这个问题,这两天让我发疯了。
$(document).ready(function () {
$(".menu").activeMenu();
$("#myCart").hide();
// Create a basic cart
$("#myCart").PayPalCart({
business: 'mypaypal@myemail.com',
notifyURL: 'http://www.diditwork.com/payment.aspx',
virtual: false, //set to true where you are selling virtual items such as downloads
quantityupdate: true, //set to false if you want to disable quantity updates in the cart
currency: 'CAD', //set to your trading currency - see PayPal for valid options
currencysign: '$', //set the currency symbol
minicartid: 'minicart', //element to show the number of items and net value
persitdays: 0 //set to -1 for cookie-less cart for single page of products,
// 0 (default) persits for the session,
// x (number of days) the basket will persits between visits
});
$(".cartImg").click(function () {
alert("your hitting it");
$("#myCart").toggle();
});
$(".closeCart").click(function () {
alert("your hitting it");
$("#myCart").hide();
});
});
【问题讨论】:
标签: javascript html jquery toggle jquery-events