开发者

How do I make an image overwrite text within another div upon hover of first div?

开发者 https://www.devze.com 2023-04-06 20:32 出处:网络
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 b

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号