Need help excluding "#div" from a function, is this possible!

Hello, I am having a problem trying to exclude some “#divs” from a scrolling function.

The problem I have is that I use a scrolling script that slides the page vertically to some defined div “#anchors

But I am trying to build some sliding tabs as well, the problem is that when clicking the tabs I am triggering the “scroll page” script instead of the tabs sliding script, so I am wondering if I can exclude the tabs menu “#divs” from the scroll page script so that there is no conflict. Please let me know if this is possible, is very important for me, thanks!

here is the scrolling script:

$(document).ready(function(){

$(‘a[href*=#]’).click(function() {
if (location.pathname.replace(/^\//,‘’) == this.pathname.replace(/^\//,‘’)

&& location.hostname == this.hostname) {
  var $target = $(this.hash);
  $target = $target.length && $target
  || $('[name=' + this.hash.slice(1) +']');
  if ($target.length) {
    var targetOffset = $target.offset().top;
    $('html,body')
    .animate({scrollTop: targetOffset}, 1000);
   return false;
  }
}

});

});

And here is what I tried doing, but it is not working:

$(document).ready(function(){

	$("#first").click(function() {

window.onbeforeunload = null;
});

$(“#second”).click(function() {
window.onbeforeunload = null;
});

$(“#third”).click(function() {
window.onbeforeunload = null;
});

$(‘a[href*=#]’).click(function() {
if (location.pathname.replace(/^\//,‘’) == this.pathname.replace(/^\//,‘’)

&& location.hostname == this.hostname) {
  var $target = $(this.hash);
  $target = $target.length && $target
  || $('[name=' + this.hash.slice(1) +']');
  if ($target.length) {
    var targetOffset = $target.offset().top;
    $('html,body')
    .animate({scrollTop: targetOffset}, 1000);
   return false;
  }
}

});

});

Hi I found a way to make it work, actually the problem is that the “#” in the main function is generic so it affects all the divs in the page, I fixed it by using
#name1, #name2 (for the scrolling anchors, that way it only affects those ones and not the #anchors of the sliding tabs)

My question is simple, sorry I am a bit of a noob in javascript

I want to put several divs in this function (right now I am just repeating the function and changing div names, but this is not so skillful.

ex…
$(‘a[href*=#div1]’).click(function() {…

$(‘a[href*=#div2]’).click(function() {…

$(‘a[href*=#div3]’).click(function() {…

how do I put "div1,div2 and #div3 on the same function, I tried:

$(‘a[href*=#div1,#div2,#div3]’).click(function() {…

but is not working, any clues? Thanks a lot!

$(‘a[href*=#div1],a[href*=#div2],a[href*=#div3]’).click(function() {…

:slight_smile:

Hey ScallioXTX!

Thanks a lot that works awesome!!, I do appreciate your help!

-Manuel