Jquery Why doesn't toggleClass work here?

wamp

I'm using this code:

$(".heading.media").click(function (event) {
    $("#cart").toggleClass("active");
    $('#cart').load('index.php?route=module/cart #cart > *');
});

But for some reason the .toggleClass("active") isn't working. It opens but I can't toggle after that.

When I remove $('#cart').load('index.php?route=module/cart #cart > *'); it works just fine.

Why does $('#cart').load('index.php?route=module/cart #cart > *'); cause trouble ?

stanze

Try selecting the element by event delegation method and try.

$(document).on('click', '.heading.media', function (event) {
    $("#cart").toggleClass("active");
    $('#cart').load('index.php?route=module/cart #cart > *');
});

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Why wmctrl doesn't work for certain windows?

분류에서Dev

Why doesn't LibreOffice work with the HUD?

분류에서Dev

Radio button jQuery change doesn't work

분류에서Dev

jquery removeClass doesn't seem to work

분류에서Dev

jQuery-UI DateTimePicker doesn't work

분류에서Dev

Why doesn't this math work with macros?

분류에서Dev

Why doesn't beep work in Ubuntu?

분류에서Dev

Jquery function on doesn't work, no alert

분류에서Dev

Why doesn't my SetLength work?

분류에서Dev

why the click() function doesn't work?

분류에서Dev

Why doesn't this Mongoose query work?

분류에서Dev

Why doesn't this simple enable_if work?

분류에서Dev

Why isEOF doesn't work?

분류에서Dev

Cakephp redirect doesn't work with jquery mobile

분류에서Dev

Why json doesn´t work?

분류에서Dev

Why doesn't isdigit() work?

분류에서Dev

Why this jQuery doesn't work in Codeigniter?

분류에서Dev

Why doesn't creating video var from jquery work and from getElementById does?

분류에서Dev

jQuery function doesn't work

분류에서Dev

In scala, why doesn't lower bound work well here?

분류에서Dev

In scala, why doesn't lower bound work well here?

분류에서Dev

Why doesn't my iptables rule work?

분류에서Dev

Why doesn't source lib/* work?

분류에서Dev

Why char[] work,but char * doesn't

분류에서Dev

toggleClass() doesn't work after first time

분류에서Dev

why doesn't history work in Ubuntu?

분류에서Dev

Why doesn't this batch command work as expected?

분류에서Dev

Why doesn't "usermod" work under superuser?

분류에서Dev

Why doesn't my .desktop file work?