简体   繁体   中英

trigger click on element that has multiple class

I have the following element:

  <a href="#" class='popup register'>Register</a>

and I want to trigger a clic action on this, how do I do this? I tried doing:

$('.popup .register').trigger('click');

but it didn't work

Remove the space between the selectors.

$('.popup.register').trigger('click');

.popup .register means that trigger click event on the element with class register which is a child of element with class popup . So in your particular scenario this won't work as they are both on the same element.

Fiddle Sample

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM