String Manipulation with jQuery and JavaScript

Hello everyone!
I will like to get the text content of a html tag in this case it is an Url and remove http:// , www, https://, http://www, https://www. here is the code that I wrote and does not work.

<div id="container">
            <span class="meta-item project-url">
                <span class="meta-label">URL</span>
                <a target="_blank" href=""></a>


        $('.project-url a').text().replace('http://', '');
        console.log($('.project-url a').text().replace('http://', ''));


The Results I can see just in the console but not in me DOM , which I want to do. This is a Web Applikation that’s why I can just manipulate it with JS .

Hi @pantera-bo

You need to pass the result of calling replace into the text function, at the moment you’re calling replace but not doing anything with the result.

Something like this:

$(document).ready(function() {
    var $url = $('.project-url a');
    $url.text($url.text().replace('http://', ''));

    console.log($('.project-url a').text().replace('http://', ''));

I think this stack overflow post will help:


many thanks to you 2 :smiley: