user11929397
user11929397

Reputation:

Django and JQuery - Find and Replace Text

I want to transfer data from one tag to the other.

This is how far I got:

<a id="oldartist"> {{ object.user }}</a>
<a id="newartist"></a>


function newArt() {
    var artistname = document.getElementById("oldartist");
    $('#newartist').text(artistname);
};

But I get

https:// mywebsite.com/johndoe

instead of

johndoe

Why is this happening and how can I fix it?

Thank you for any help

Upvotes: 1

Views: 59

Answers (1)

devdob
devdob

Reputation: 1504

You are adding the <a> element as is into the tag, it needs to be,

function newArt() {
   var artistname = document.getElementById("oldartist").text;
   $('#newartist').text(artistname);
};

Upvotes: 1

Related Questions