document.getElementById("change").onmouseover = function() {
changeingFont();
};
document.getElementById("change").onmouseout = function() {
normalFont();
};
function changeingFont() {
document.getElementById("chnage").style.fontSize = "25px";
}
function normalFont() {
document.getElementById("change").style.fontSize = "15px";
}
对于代码
我在 HTML(标签(中有超链接,当我用鼠标悬停文本时,文本必须更大。这行不通...我不知道为什么。。。有人可以帮助我吗?
直接的答案是错别字,但我想提供更多的东西来帮助你改进。您正在覆盖onmouseover
和onmouseout
事件处理程序,但我们可以更好一点并使用侦听器:
const change = document.getElementById("change");
change.addEventListener("mouseover", () => changeFont());
change.addEventListener("mouseout", () => normalFont());
function changeFont() {
change.style.fontSize = "25px";
}
function normalFont() {
change.style.fontSize = "15px";
}