Possible Duplicate:
jQuery attribute selector for multiple values
Suppose that I have the following:
<a href="#" class="result-name" data-role="1" data-obj-id="15">Obj 15</a>
<a href="#" class="result-name" data-role="3" data-obj-id="19">Obj 19</a>
<a href="#" class="result-name" data-role="2" data-obj-id="20">Obj 20</a>
Right now, I’m doing something like this:
$(document).on('click', 'a.result-name', function() {
var objId = $(this).data('obj-id');
// do some ajax call...
});
Now, if I want to call add this behavior only in the links with role 1 or 3, and I want to do that in the selector, how can I do that?
I tried:
$(document).on('click', 'a.result-name[data-role=1|3]', function() { //...
without success.
Use comma to attach event to multiple elements
http://jsfiddle.net/RSwMw/2/
Also you can use
NotEqualselector!=http://jsfiddle.net/RSwMw/1/