javascript - Django 和 JQuery - 查找和替换文本

标签 javascript jquery django

我想将数据从一个标签传输到另一个标签。

这是我得到的结果:

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


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

但是我明白了

https:// mywebsite.com/johndoe

代替

johndoe

为什么会发生这种情况,我该如何解决?

谢谢你的帮助

最佳答案

您正在添加 <a>标签中的元素,它需要,

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

关于javascript - Django 和 JQuery - 查找和替换文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58466969/

相关文章:

javascript - 使用 Node.js 查询 twitter api 但出现错误

javascript - 将变量从 .CTP View 设置为 .JS

javascript - jQuery 平滑改变 innerHTML

python - 如何在不重新加载的情况下返回主页

python - 带有 apache ldap 后端身份验证的 django,登录用户名和 ldap 组并隐藏基于组的详细信息 (mod_ldap)

sql - 将 get_absolute_url 组合成 django 中的原始 SQL 语句

javascript - 通过 JavaScript 或 jQuery 控制 CSS

php - 使用ajax和php传递数组

Jquery循环数据

jquery - 重力形式总字段在 WordPress 页面中不起作用