简体   繁体   中英

jQuery: Multiple selectors in a single variable

I'd like to create a function triggerd by certain classes. I tried it like that but it didn't work:(

var ajaxlinks = $(".ajaxlink") $(".navlinks").find('a');

ajaxlinks.click(function(e){ ... }

What am I doing wrong?

You can use a , to separate different selectors:

$(".ajaxlink, .navlinks").find("a");

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