如何在悬停第一个div时让图像覆盖另一个div中的文本? ?非常感谢任何帮助。
答案 0 :(得分:0)
window.onload = function () { // ensure that we don't try to get div1 before it's loaded
document.getElementById("div1").onmouseover = function () {
document.getElementById("div2").innerHTML = "<p>new HTML</p>";
};
};
根据您的情况,您可能希望使用innerText属性来确保您不会意外地制作HTML,或者您可以use the DOM制作新元素。