Reputation:
I have the following:
$('#editMenu', '#createContent', '#editContent')
.click(function () {
var $link = $(this);
if ($link.attr('data-disabled') === 'no') {
$link.attr('data-disabled', 'yes');
adminDialog($link);
}
return false;
});
However it seems like clicking on any of these does not work. Am I setting it up correctly?
Upvotes: 0
Views: 55
Reputation: 29549
jQuery allows for multiple selectors like so:
jQuery('selector1, selector2, selectorN')
so you would need:
$('#editMenu, #createContent, #editContent')
You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order. An alternative to this combinator is the .add() method.
Upvotes: 0
Reputation: 79830
What you are trying is multiple selector
which should be written as a single string with comma separated selector. See below,
Change
$('#editMenu', '#createContent', '#editContent')
to
$('#editMenu, #createContent, #editContent')
Upvotes: 5