How can i use AND(&&) operator in jQuery?
How can i use one click event for two different type of elements here is my code that does not work.
$('li. selectable a')&&am开发者_Python百科p;('td.selectable a').click(function() { .... });
Change the selector to select both:
$("li.selectable a, td.selectable a").click(...
Use the multiple selector. Also known as the comma.
$('li.selectable a, td.selectable a').click(function() {
Of course you could here reduce this to
$('.selectable a').click(function() {
This would, however, be slightly slower in most browsers.
Comma does not work?
$('li.selectable a, td.selectable a').click(function() {
Just use a comma:
$('li. selectable a, td.selectable a').click(function() {
Cheers
Or more up to date:
$('li.selectable a, td.selectable a').on('click', function() {
// Execute code...
)};
精彩评论