Reputation: 14387
We have a requirement in application that on clicking on all images which do not have a css class of "xyz" we want to call a function. We are trying to write it somehwhat like this:
$('input[type=image] class=xyz').click(function(){//something});
It doesn't seem to work. Ideal scenario would be that all images on clicking does some functionality except the one which has CSS as "xyz".
What am I doing wrong?
I am using input, as I use JSF and this command button is being displayed as an input type component with src as image.
Thanks for your help in advance. Cheers
Upvotes: 3
Views: 6909
Reputation: 31761
I think you want to use not.
This should do it:
$('input[type=image]').not(".xyz").click(function(){//something});
You may also be able to use the not selector.
$('input[type=image]:not(.xyz)').click(function(){//something});
The function version seems more expressive to me.
Upvotes: 7
Reputation: 321588
This should do it:
$('input[type=image]:not(.xyz)').click(function(){//something});
Upvotes: 1
Reputation: 294
try this:
$('input[type=image][class!=xyz]').click(function(){//something});
Upvotes: 1
Reputation: 40497
you can remove elements from selection having certain class or id using not function:
$("input[type=image]").not(".xyz").click(function(){....});
Upvotes: 1
Reputation: 67137
We have a requirement in application that on clicking on all images which do not have a css class of "xyz" we want to call a function.
That should be pretty intuitive using JQuery:
Code:
$('input[type=image],img').not('.xyz').click(myFunc);
Upvotes: 1