[英]Jquery Why doesn't toggleClass work here?
我正在使用此代碼:
$(".heading.media").click(function (event) {
$("#cart").toggleClass("active");
$('#cart').load('index.php?route=module/cart #cart > *');
});
但是由於某種原因, .toggleClass("active")
無法正常工作。 它會打開,但此后我無法切換。
當我刪除$('#cart').load('index.php?route=module/cart #cart > *');
它工作正常。
為什么$('#cart').load('index.php?route=module/cart #cart > *');
引起麻煩 ?
嘗試通過事件委托方法選擇元素,然后嘗試。
$(document).on('click', '.heading.media', function (event) {
$("#cart").toggleClass("active");
$('#cart').load('index.php?route=module/cart #cart > *');
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.