Javascript 通过 jQuery 更改链接 href
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14141307/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change link href via jQuery
提问by Slaythern Aareonna
Possible Duplicate:
How to change the href for a hyperlink using jQuery
可能的重复:
如何使用 jQuery 更改超链接的 href
I'm using Drupal and system generate my title.
我正在使用 Drupal 和系统生成我的标题。
E.G.
例如
<a class="jquery-once-3-processed" id="quicktabs-tab-galeri-1"
href="/?q=node&qt-galeri=1#qt-galeri">NEWS</a>
I want change this hreflink via jQuery. How can i do this? Thank you.
我想href通过 jQuery更改此链接。我怎样才能做到这一点?谢谢你。
回答by jxpx777
$("#quicktabs-tab-galeri-1").attr("href", new_href);
That should do the trick for you.
那应该对你有用。
回答by Pablo
$('#quicktabs-tab-galeri-1').attr('href', 'YOUR_NEW_HREF');
This selects the element with id quicktabs-tab-galeri-1and changes its hrefattribute.
这将选择 id 为quicktabs-tab-galeri-1的元素并更改其href属性。
回答by geedubb
You can try:
你可以试试:
$('#quicktabs-tab-galeri-1').attr("href", "http://yournewlink.com");

