What is the most efficient way to filter the list of classes on a given element?
<div class="foo bar"></div>
<div class="bim bar"></div>
$("div.bar").click(function(ev) {
alert("The non-bar class was:" + ???);
});
I know I could write a for-loop to go through the ev.currentTarget.classList but I want to know if there’s a better way.
EDIT: I’d like to clarify that I want the alert to tell me “foo” and “bim.” I don’t want to replace “bar,” I just want to be able to access the classes that are NOT bar. Thanks.
There’s no jQuery way to get this, but I would do:
See it in action here: http://jsfiddle.net/PpUeX/2