Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript-如何检测是否为onmouseover?_Javascript_Html_Events_Dom_Onmouseover - Fatal编程技术网

javascript-如何检测是否为onmouseover?

javascript-如何检测是否为onmouseover?,javascript,html,events,dom,onmouseover,Javascript,Html,Events,Dom,Onmouseover,我有一个使用onmouseover使元素display=block的脚本 <script language="JavaScript"> function aaa() { document.getElementById('cat').style.display = "block"; } </script> <a href='#' onmouseover='aaa()'>hover on me</a> <div id='cat'

我有一个使用onmouseover使元素display=block的脚本

<script language="JavaScript">
function aaa() 
{
    document.getElementById('cat').style.display = "block";
}
</script>

<a href='#' onmouseover='aaa()'>hover on me</a>

<div  id='cat' style='display:none;'>this will show</div>
                function aaa()
                {
                    document.getElementById('cat').style.display = "block";
                }
                function bbb()
                {
                    document.getElementById('cat').style.display = "none";
                }

        <a href='#' onmouseover='aaa()' onmouseout="bbb();">hover on me</a>
        <div id='cat' style='display: none;'>this will show</div>

函数aaa()
{
document.getElementById('cat').style.display=“block”;
}
这将显示
我想在鼠标不在屏幕上时将该元素返回到其原始显示属性(无)

"<a href='#' onmouseover='aaa()'>hover on me</a>"
                function aaa()
                {
                    document.getElementById('cat').style.display = "block";
                }
                function bbb()
                {
                    document.getElementById('cat').style.display = "none";
                }

        <a href='#' onmouseover='aaa()' onmouseout="bbb();">hover on me</a>
        <div id='cat' style='display: none;'>this will show</div>
“”

我该怎么做呢?

这里有
onmouseout
事件

function bbb() 
{
    document.getElementById('cat').style.display = "none";
}
                function aaa()
                {
                    document.getElementById('cat').style.display = "block";
                }
                function bbb()
                {
                    document.getElementById('cat').style.display = "none";
                }

        <a href='#' onmouseover='aaa()' onmouseout="bbb();">hover on me</a>
        <div id='cat' style='display: none;'>this will show</div>

<a href='#' onmouseover='aaa()' onmouseout='bbb()'>hover on me</a>
                function aaa()
                {
                    document.getElementById('cat').style.display = "block";
                }
                function bbb()
                {
                    document.getElementById('cat').style.display = "none";
                }

        <a href='#' onmouseover='aaa()' onmouseout="bbb();">hover on me</a>
        <div id='cat' style='display: none;'>this will show</div>

您应该使用
onMouseOut
事件,代码如下所示

<a href='#' onmouseover='show();' onmouseout='dontShow();'>hover</a>
<div  id='cat' style='display:none;'>this will show</div>​



function show() {
    document.getElementById('cat').style.display = "block";
}

function dontShow() {
    document.getElementById('cat').style.display = "none";
}
                function aaa()
                {
                    document.getElementById('cat').style.display = "block";
                }
                function bbb()
                {
                    document.getElementById('cat').style.display = "none";
                }

        <a href='#' onmouseover='aaa()' onmouseout="bbb();">hover on me</a>
        <div id='cat' style='display: none;'>this will show</div>

这将显示​
函数show(){
document.getElementById('cat').style.display=“block”;
}
函数dontShow(){
document.getElementById('cat').style.display=“无”;
}
演示:

                function aaa()
                {
                    document.getElementById('cat').style.display = "block";
                }
                function bbb()
                {
                    document.getElementById('cat').style.display = "none";
                }

        <a href='#' onmouseover='aaa()' onmouseout="bbb();">hover on me</a>
        <div id='cat' style='display: none;'>this will show</div>
HTML:

                function aaa()
                {
                    document.getElementById('cat').style.display = "block";
                }
                function bbb()
                {
                    document.getElementById('cat').style.display = "none";
                }

        <a href='#' onmouseover='aaa()' onmouseout="bbb();">hover on me</a>
        <div id='cat' style='display: none;'>this will show</div>
这将帮助您……

                function aaa()
                {
                    document.getElementById('cat').style.display = "block";
                }
                function bbb()
                {
                    document.getElementById('cat').style.display = "none";
                }

        <a href='#' onmouseover='aaa()' onmouseout="bbb();">hover on me</a>
        <div id='cat' style='display: none;'>this will show</div>
函数aaa()
{
document.getElementById('cat').style.display=“block”;
}
函数bbb()
{
document.getElementById('cat').style.display=“无”;
}
这将显示

我正在考虑提供与示例相同的代码u。如果在onMouseout()函数中包含原始显示属性,则当鼠标未停下来时,将返回原始属性

                function aaa()
                {
                    document.getElementById('cat').style.display = "block";
                }
                function bbb()
                {
                    document.getElementById('cat').style.display = "none";
                }

        <a href='#' onmouseover='aaa()' onmouseout="bbb();">hover on me</a>
        <div id='cat' style='display: none;'>this will show</div>
<script language="JavaScript">
function aaa() 
{
    document.getElementById('cat').style.display = "block";
}
function bbb()
{
//include the code TO CHAGE THE PROPERTY HERE
document.getElementById('cat').style.display = "      ";
}
</script>

<a href='#' onmouseover='aaa();' onmouseout="bbb();">hover on me</a>

<div  id='cat' style='display:none;'>this will show</div>

函数aaa()
{
document.getElementById('cat').style.display=“block”;
}
函数bbb()
{
//在此处包含更改属性的代码
document.getElementById('cat').style.display=“”;
}
这将显示

下次,在询问之前用谷歌搜索。