开发者

Multiple Selectors doing the same thing in Jquery

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜