I'm loading wordpress pages dynamically using ajax. It fires properly but I need to exclude a specific anchor.
<a href="http://store.myurl.com" target="_blank" title="Store">Store</a>
I thought using .not() would work like so
$('a').not('a[title=Store]').live('click',function() {
But t开发者_Go百科hat breaks the whole thing.
If I use $('a').live('click',function() {
it fires properly.
p.s. I can't change the anchor output like ad an ID or a Class.
Does the attribute selector work without quotes? I would use
$('a').not('a[title="Store"]').live('click',function() {
you are missing the mandatory quotes on the attribute selector. try
$('a:not(a[title="Store"])').live('click',function()
edit:
the live is not going to bind against elements returned by a filter (as .not()
), you need a selector to match against when .live()
resolves in body (where it is binded). so you need to use the :not
selector, plus using the quotes for the attribute selector
You can try using the :not
selector instead:
$('a:not([title="Store"])').live('click', function(){
Try:
$('a').not('[title=Store]').live('click',function() {
(I removed the letter "a" before "[title=Store]")
精彩评论