How do I clear inner HTML

前端 未结 4 1747
盖世英雄少女心
盖世英雄少女心 2021-02-03 23:03

I\'ve been fiddling with this for a while but it won\'t work and I can\'t figure out why. Please help. Here is what I have:



    

        
4条回答
  •  孤城傲影
    2021-02-03 23:19

    The h1 tags unfortunately do not receive the onmouseout events.

    The simple Javascript snippet below will work for all elements and uses only 1 mouse event.

    Note: "The borders in the snippet are applied to provide a visual demarcation of the elements."

    document.body.onmousemove = function(){ move("The dog is in its shed"); };
    
    document.body.style.border = "2px solid red";
    document.getElementById("h1Tag").style.border = "2px solid blue";
    
    function move(what) {
        if(event.target.id == "h1Tag"){ document.getElementById("goy").innerHTML = "what"; } else { document.getElementById("goy").innerHTML = ""; }
    }

    lalala

    This can also be done in pure CSS by adding the hover selector css property to the h1 tag.

提交回复
热议问题