I have the following selectors:
$('#menu a[href^="/C"]').live('click', function (event) { } )
$('#menu a[href^="/T"]').live('click', function (event) { } )
One selects href that starts with /C and the other /T
Is there a way that I can combine these?
多个jquery选择器可以用逗号分隔:
$('#menu a[href^="/C"], #menu a[href^="/T"]').live('click',function(e){});
The selectors you gave were exactly the same, but in general all you have to do is comma delimit the two selectors like the following:
$('#firstSelector, #secondSelector');
For more information check out the jquery site on mutiple selectors
Edit:
This should be what you are looking for:
$('#menu a[href^="/C"], #menu a[href^="/T"]').live('click',function(e){});
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.