在我的网站中,我有一个这样的 div
<div class="yjme_item_in yjmeitem29">
这个div里面有一个链接,我想替换它的href,引入www.google.com。
有什么想法吗?
我已经尝试过了,但没有成功
var a = document.getElementsByClassName("yjmeitem29")[0];
a.setAttribute("href", "www.google.es");
最佳答案
试试这个
a.childNodes[0].setAttribute("href", "www.google.es");
关于javascript - 如何替换有关 javascript 中的类的链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23879604/