remove specific characters or tags in href by using jquery

I’m editing a WordPress theme.

I have something like this in a WordPress loop:

Read More
<a class="link" href="<?php the_content(); ?>"></a>

Which will turn into something into like this cause by WordPress:

<a class="link" href="<p>http://google.com</p>"></a>

How do I remove the <p></p> tags inside the href by using jquery? I have multiple of these in a loop.

Related posts

1 comment

  1. You could also do this very easily without jQuery as well:

    var links = document.getElementsByClassName('link');
    for (var i = 0, j = links.length; i < j; i++) {
        var href = links[i].getAttribute('href');
        href = href.replace('<p>', '').replace('</p>', '');
        links[i].setAttribute('href', href);
    }
    

Comments are closed.