[jQuery] remove in-page links with plain text

[jQuery] remove in-page links with plain text

Try matching the url with this: $("a[@href*='"+url+"']").each(....
It should find a match whether the url is absolute or relative.
Ryan Rose
http://www.digiwize.com
-----Original Message-----
From: discuss-bounces@jquery.com [mailto:discuss-bounces@jquery.com] On
Behalf Of George Adamson
Sent: Saturday, January 27, 2007 9:15 AM
To: discuss@jquery.com
Subject: Re: [jQuery] remove in-page links with plain text
Removing self-links from a page is good plan though it will only work
for
js-enabled users. Standard readers will still see the full links so this
is
not a very accessible solution. Best to do it server-side if possible.
Anyway, regarding your specific questions:
> 1) "I need a way to not to add the span tag for any links under who's
> parent node is a H1."
Not sure what you mean about the span tag, sorry. Can you use .filter()
or
.not() to do this?
> 2) "in need of tiding up..."
Here's some code to simplify things a bit:
    var url = document.location.href;
    $("A[@href='" + url + "']").each(function(){
        var $this = $(this);
        var txtEl = document.createTextNode( $this.text() );
        $this.parent()[0].replaceChild(txtEl, this);
    })
A word of caution: When reading A.href from code code you may find it
varies
depending on the browser. It may or may not include the full url path.
This
will cause it not match the document.location.href. Perhaps you could
experiment with "$=" instead of "=" in the selector syntax (see jquery
selector docs)
George
ProDevStudio




































    • Topic Participants

    • rrose