SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    External link not working with jquery

    Hello,

    I've created a horizontal scrolling site using the following:

    $(document).ready(function() {
    $("#nav a").bind("click",function(event){
    event.preventDefault();
    var target = $(this).attr("href");
    $("html, body").stop().animate({
    scrollLeft: $(target).offset().left,
    scrollTop: $(target).offset().top
    }, 1100);
    });
    });

    which is working fine, however, some of the external links on my page are now not working.

    What have I done wrong? Please help!!!!!

  2. #2
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Do you have any external links in your #nav element? Because you do "event.preventDefault()" on every single "#nav a," and if you have external links in there, it wouldn't follow them.

    If that's not it, we might need a link to the actual site.
    I'm the web overlord for Graphic Business Systems

  3. #3
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I do have the external link in one of my #nav elements and your explanation makes perfect sense.

    THANK YOU SO MUCH!!!!!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •