How do I make an image overwrite text within another div upon hover of first div?
How do I make an image overwrite text within another div upon hove开发者_开发百科r of first div? ? Any help greatly appreciated.
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>";
};
};
Depending on your case, you may wish to use the innerText property to ensure that you don't accidentally make HTML, or you can use the DOM to make new elements.
精彩评论