• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

jQuery: Select element where class NOT xyz

How can I select an element using find() only if the class is NOT xyz?
$('.featured>span').find('a  CLASS NOT .xyz ').click(function() { alert(123) });

Open in new window

0
hankknight
Asked:
hankknight
  • 2
  • 2
3 Solutions
 
chaitu chaituCommented:
$('.featured > span').not('.xyz ').click(function() { alert(123) });

0
 
chaitu chaituCommented:
$('.featured > span').not('a.xyz ').click(function() { alert(123) });

0
 
leakim971PluritechnicianCommented:
Test page : http://jsfiddle.net/m8vmy/

$("a", '.featured>span').not('a.xyz ').click(function() { alert(123) });
//$('.featured>span').find("a").not('a.xyz ').click(function() { alert(123) }); // work too

Open in new window

0
 
sonawanekiranCommented:
This will also work

 $('.featured > span a').not('.xyz ').click(function() { alert(123) });
0
 
sonawanekiranCommented:
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now