用 javascript 更改所有 hrefs?
Change all a hrefs with javascript?
如何在页面加载时使用自定义 URL 更改所有 href?
抱歉,我不知道该怎么做。真的不懂js.
感谢任何能帮助我的人。非常感谢。
你可以使用这个:
// Execute this when the document is ready.
window.onload = function () {
// Get all the `<a>` tags.
var all_a = document.querySelectorAll("a");
// Loop through all the `<a>` tags.
for (i = 0; i < all_a.length; i++)
// Change the `href`:
all_a[i].setAttribute("href", "whatever_you_want");
}
如何在页面加载时使用自定义 URL 更改所有 href?
抱歉,我不知道该怎么做。真的不懂js.
感谢任何能帮助我的人。非常感谢。
你可以使用这个:
// Execute this when the document is ready.
window.onload = function () {
// Get all the `<a>` tags.
var all_a = document.querySelectorAll("a");
// Loop through all the `<a>` tags.
for (i = 0; i < all_a.length; i++)
// Change the `href`:
all_a[i].setAttribute("href", "whatever_you_want");
}