Combining selectors?

后端 未结 3 1517
遥遥无期
遥遥无期 2021-01-25 11:24

I have two click events as follows:

$($(\'[id^=\"tab\"]\')).live(\'click\', function() {
    alert($(this).attr(\"id\"));
});

$($(\'[id^=\"home\"]\')).live(\'cl         


        
3条回答
  •  [愿得一人]
    2021-01-25 12:14

    Sure, simply divide them by ,:

    $('[id^="tab"], [id^="home"]').live('click', function() {
        alert($(this).attr("id"));
    });
    

提交回复
热议问题