2013-12-18 5 views
-2

i am noob в этом одном, поэтому я хотел спросить вас, возможно, вы знаете, как выбрать все элементы, кроме одного.Javascript not selector

Вот скрипт:

<script type="text/javascript"> 
    var jump = function (e) { 
     //prevent the "normal" behaviour which would be a "hard" jump 
     e.preventDefault(); 
     //Get the target 
     var target = $(this).attr("href"); 
     //perform animated scrolling 
     $('html,body').animate({ 
      //get top-position of target-element and set it as scroll target 
      scrollTop: $(target).offset().top 
      //scrolldelay:1 seconds 
     }, 1000, function() { 
      //attach the hash (#jumptarget) to the pageurl 
      location.hash = target; 
     }); 
    } 
    $(document).ready(function() { 
     $('a[href*=#]').bind("click", jump); 
     return false; 
    }); 
</script> 
<!-- // end of smooth scrolling --> 

И я хочу сделать такой же эффект на все ссылки, кроме #myCarousel. Вопрос в том, как это сделать и где нужно включать: не селектор в скрипте.

Заранее спасибо.

+0

http://api.jquery.com/not-selector/ – sbking

ответ

1

вы могли бы использовать .not(), как:

$('a[href*=#]').not('#myCarousel').bind("click", jump); 
+0

Это решило мою проблему. $ (document) .ready (function() { //$('a[href*=#]').bind("click ", jump); $ ('a [href * = #] ') .not (document.getElementsByClassName («управление карусель»)). bind («click», jump); return false; }); – mixy

0

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

$('a[href*=#]:not(#myCarousel)').bind("click", jump);