Trigger event listener
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
精彩评论