Get help. Give help. A Web Design and Development Community.

target xlink:href with jQuery?

  • # May 22, 2013 at 6:42 pm


    I’m using this code to animate scrolling on all my anchor tags:

    $(‘a[href*=#]:not([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) {
    scrollTop: target.offset().top
    }, 1000);
    return false;

    The code works great but I have some links in an SVG and it’s not targeting them. jQuery doesn’t seem to recognize the attribute “xlink:href”. Is there any way to accomplish this?

    Thanks in advance.

    # May 22, 2013 at 10:47 pm

    I fixed this myself with a workaround. For anyone that may search this in the future, I used


    instead of “xlink:href”. My function looks like:

    function specialfunction(){
    scrollTop: $(‘#target’).offset().top
    }, 1000);
    return false;

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We have a pretty good* newsletter.