开发者

Trigger event listener

开发者 https://www.devze.com 2023-04-13 07:50 出处:网络
I am currently making a website with the use of simpleCart(js)(open jQuery Shopping Cart). In html this fires the event to empty the shopping cart:

I am currently making a website with the use of simpleCart(js)(open jQuery Shopping Cart).

In html this fires the event to empty the shopping cart:

<a class="simpleCart_empty" href="javascript:;"开发者_高级运维></a>

I would like to combine this event with a few other action so I try to fire it on my commend without actually clicking on the link.

The source has this:

 me.addEventToArray( getElementsByClassName('simpleCart_empty') , simpleCart.empty , "click" );

Does anyone no how to trigger it in jQuery? Or how to find how to do that? A regular:

 $(".simpleCart_empty").trigger('click');

doesn't work, and seems like a wrong workaround.

The code:

$(simpleCart.empty).trigger('click');

Does the trick.


Did you try

$(".simpleCart_empty").click();


Try using the bind() function of jQuery

 $('.simpleCart_empty').bind('click', function() {
     alert('Should empty cart');
 });

Just replace the alert with the actions you want to execute

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号