jquery - jQuery 将文本添加到 URL 的末尾
问题描述
我有这个代码:
$('a.comment-reply-link').each(function(){
this.href = this.href.replace("dummy_comment", "author");
this.href = this.href.replace("#comment-", "?replytocom=");
});
这是有效的,但现在我想在 url #respond 的末尾。所以我把代码写成:
$('a.comment-reply-link').each(function(){
this.href = this.href.replace("dummy_comment", "author");
this.href = this.href.replace("#comment-", "?replytocom=");
this.href + '#respond';
});
但这不起作用?我怎样才能让它工作?
解决方案
尝试改变
this.href + '#respond';
对此
this.href += '#respond';
推荐阅读
- python - 如何翻转火炬中的张量部分?
- git - 我有一个远程起源分支。在本地,我有一个主分支和测试分支。如何在不提交的情况下拉到测试分支?
- karate - 空手道机器人:无法使用图像单击按钮
- python - 如何使用 tf.data.dataset 进行多输出和损失训练?
- elasticsearch - Elastic Search 对一个文档执行计算
- java - 无法映射枚举值时如何配置 MapStruct 以引发异常
- linux - 在两台机器上的 GNU/Linux 上唤醒 WLAN:一台工作,另一台不工作
- excel - 在 var 中存储日期时出现运行时错误“6”溢出
- php - 如何使用 Symfony 客户端重命名 webdav 集合?
- ubuntu - .net core mvc API 使用 NGINX 反向代理部署在 UBUNTU 上,POST 请求抛出 404 错误