2014-09-02 2 views
1

У меня есть эта строка и этот код, она работает: нет ([href^= "mailto:"]), поэтому я исключил ссылки с «mailto» и знаю Я хочу исключить ссылку с определенным идентификатором. Как я могу сделать ?Используйте «нет» в JQuery

$(function() { 
    var speed = 'slow'; 

    $(".loader").fadeOut(speed, function() { 
     $('a[href]:not([href^="mailto:"])').on('click', function(event) { 
      event.preventDefault(); 

      var url = $(this).attr('href'); 

      if (url.indexOf('#') !== 0 && url.indexOf('javascript:') !== 0) { 

       $(".loader").fadeIn(speed, function() { 
        window.location = url; 
       }); 
      } 

     }); 
    }); 
}); 
+5

http://stackoverflow.com/questions/4545211/jquery-not-multiple-excludes-with-id ? –

+2

Или: http://stackoverflow.com/q/5684160/218196 –

ответ

0
$('a[href]:not([href^="mailto:"]):not(#your_ID)').on('click', function(event) { 

Это должно сделать работу.

+0

': not (" # your_ID ")' должно быть ': not (#your_ID)'. –

+0

Япс, это правильно. – bayerphi

1
$('a[href]:not([href^="mailto:"])').not("#yourIdHere") 
1

Вы можете использовать:

$('a[href]:not([href^="mailto:"]):not(#the-id-to-exclude)')... 

Или:

$('a[href]:not([href^="mailto:"])').not('#the-id-to-exclude').... 
+0

': not (" # the-id-to-exclude ")' должно быть ': not (# the-id-to-exclude)' –

+1

Спасибо @FelixKling! Обновлено. – PeterKA

Смежные вопросы