javascript-如何检测是否为onmouseover?
我有一个使用onmouseover使元素display=block的脚本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'
<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=“”;
}
这将显示
下次,在询问之前用谷歌搜索。