Combining selectors?

后端 未结 3 1516
遥遥无期
遥遥无期 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:09
    $('[id^="home"], [id^="tab"]')
    
    0 讨论(0)
  • 2021-01-25 12:10
    $('[id^="tab"], [id^="home"]').live('click', function() {
        alert($(this).attr("id"));
    });
    

    http://jsfiddle.net/yUYVh/3/

    0 讨论(0)
  • 2021-01-25 12:14

    Sure, simply divide them by ,:

    $('[id^="tab"], [id^="home"]').live('click', function() {
        alert($(this).attr("id"));
    });
    
    0 讨论(0)
提交回复
热议问题