如何使用jQuery更改超链接的href?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("a").each(function(){
var href = $(this).attr('href');
alert(href);
var reg =href+'hiii' ;
alert(reg);
$(this).attr("href", reg);
alert($(this).text())
});
});
</script>
<button>Alert the value of each list item</button>
<ul>
<a href="yuyuyuyuyuy"><p>If you click on me, I will disappear.</p></a>
<a href="ioooo"><p>If you click on me, I will disappear.</p></a>
</ul>
这就是你可以如何改变甚至编辑网站上联盟链接编辑的链接工作删除jquery alart
答案 0 :(得分:1)
这是谷歌搜索的基本用法。
答案是: 1.为此标记设置ID,如此
<a id="my_link"></a>
然后使用jquery更改它:
$("#my_link").attr("href", "your_link")