开发者

Multiple Selectors doing the same thing in Jquery

开发者 https://www.devze.com 2023-03-01 04:55 出处:网络
I have this: $(\'.Gallery a\').click(function(event) { event.preventDefault(); window.open ($(this).attr(\'href\'),\"Gallery\",\"menubar=1,resizable=1,width=500,height=600\");

I have this:

$('.Gallery a').click(function(event) {
        event.preventDefault();
        window.open ($(this).attr('href'),"Gallery","menubar=1,resizable=1,width=500,height=600");
    });

basically I want it to also happenin when $('.popup a') is also clicked, how do you开发者_如何学Python have multiple click events do the same thing with different CSS classes. I hope that makes sense.


You can put two things in the same selector:

$('.Gallery a, .popup a').click(function(event) {
    event.preventDefault();
    window.open ($(this).attr('href'),"Gallery","menubar=1,resizable=1,width=500,height=600");
});


Use multiple selectors , CSS style:

$('.Gallery a, .popup a').click(function(event) {
        event.preventDefault();
        window.open ($(this).attr('href'),"Gallery","menubar=1,resizable=1,width=500,height=600");
    });
0

精彩评论

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