1

I have this line and this code, it works : not([href^="mailto:"]), so I excluded the links with the "mailto", and know I want to exclude a link with a specific ID. How can I do ?

$(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;
                });
            }

        });
    });
}); 
user3870112
  • 311
  • 3
  • 18

3 Answers3

1
$('a[href]:not([href^="mailto:"])').not("#yourIdHere" )
subas_poudel
  • 456
  • 2
  • 17
1

You can use either:

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

Or:

$('a[href]:not([href^="mailto:"])').not('#the-id-to-exclude')....
PeterKA
  • 24,158
  • 5
  • 26
  • 48
0
$('a[href]:not([href^="mailto:"]):not(#your_ID)').on('click', function(event) {

This should do the Job.

bayerphi
  • 325
  • 1
  • 4
  • 12