jQuery: How to select all elements which have an attribute that is not equal to specific value?
How could I select in jQuery all elements that have the my_attr attribute which is not equal to my_value ?
If my_attr is a and my_value is "4", it should work like this:
<span>Hello</span> => Not selected <span a="5">Stack</span> => Selected <span b="4">Overflow</span> => Not selected <span a="4">!!</span> => Not selected
If you want it to equal, just take out the ! for an attribute-equals selector, like this:
To use a variable, just concatenate, like this:
$("span[" + my_attr + "][" + my_attr + "!='" + my_value + "']")