【问题标题】:Is there a way to change the destination of a link with a click with jQuery? [duplicate]有没有办法通过点击 jQuery 来更改链接的目的地? [复制]
【发布时间】:2020-04-27 03:34:28
【问题描述】:

类似

<a href="www.somewhere.com">Click here.</a>

<div class="button">Button</div> /* when pressed, "href" link changes */

当按下按钮时。 “www.somewhere.com”被更改为不同的 URL?

谢谢。

【问题讨论】:

标签: javascript jquery html


【解决方案1】:

是的。选择按钮并更改href 属性。

$("button").on("click", () => {
    $("a").attr("href", "newlink");
});

【讨论】:

  • 点赞!做得很好。
猜你喜欢
  • 2015-10-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-25
  • 2012-12-18
  • 2020-08-26
  • 1970-01-01
  • 2014-10-16
相关资源
最近更新 更多