$('#divid a').removeAttr('href');

would only remove the attribute so you would end up with

"<p>i love <a>my website</a> and you
should too.</p>"

If i'm not mistaken.

But i have a question for Richard. Why would you want to add a span if the link is not important in the second example?

$('#divid a').each(function() {
 $(this).before($(this).text()).remove();
});


-- David


Alexandre Plennevaux schreef:
i'm curious: is this  $('#divid a').removeAttr('href');     the way to
"strip tags" ? Like "<p>i love <a href="http://www.domain.com";>my website</a> and you should too.</p>" would become:
"<p>i love my website and you should too.</p>"

Or will it only remove the href attribute?

________________________________

From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Richard D. Worth
Sent: mardi 4 septembre 2007 12:09
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Strip a href links from a div


On 9/3/07, David Duymelinck <[EMAIL PROTECTED]> wrote:

        bsuttis schreef:
        > Is it possible to strip links from a designated div with jquery?
I've
        > searched for a stripping mechanism, but haven't had any luck yet.
        >
        > I realize my request is pretty strange, I realize it'd be easier
to > not create links in the first place, but before I do that, I'm
just
        > curious about jquery's abilities.
        >
        >
        >
        $('#divid a').remove();
        
        should do it
        
        --
David Duymelinck
        


or, just in case you want to remove the hyperlink, but leave the text:

$('#divid a').removeAttr('href');

or, if you no longer want them to be anchor elements, but just text:
$('#divid a').each(function() {
  $(this).before('<span>' + $(this).text() + '</span>').remove();
});

- Richard



Ce message Envoi est certifié sans virus connu.
Analyse effectuée par AVG.
Version: 7.5.485 / Base de données virus: 269.13.3/986 - Date: 3/09/2007
9:31




--
David Duymelinck
________________
[EMAIL PROTECTED]

Reply via email to