tags:

views:

61

answers:

2

I want to setup a click event trigger in jQuery for certain anchor tags.

I want to open certain links in a new tab while ignoring ones with a certain class (before you ask I cannot put classes on the links I am trying to catch as they come from a CMS).

I want to exclude links with class "button" OR "generic_link"

I have tried

$(".content_box a[class!=button]").click(function (e) 
{
    e.preventDefault();     
    window.open($(this).attr('href'));
});

But that doesn't seem to work, also how do I do an OR statement to include "generic_link" in the exclusion?

Many thanks

+1  A: 

use this..

$(".content_box a:not('.button')")

sushil bharwani
+1  A: 

Try not functon

$(".content_box a").not(".button")

more about this : http://api.jquery.com/not/

Pranay Rana
So I could do:$(".content_box a").not(".button").not(".generic_link").click(function (e)...?
Alex Crooks
This is working thank you very much everyone
Alex Crooks