Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/395.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 不再使用jQuery悬停时隐藏_Javascript_Jquery_Html_Css_Web - Fatal编程技术网

Javascript 不再使用jQuery悬停时隐藏

Javascript 不再使用jQuery悬停时隐藏,javascript,jquery,html,css,web,Javascript,Jquery,Html,Css,Web,我希望div#reloadWarningBackground仅在将鼠标悬停在按钮#reloadButton上时显示 这是我的密码: $('#reloadButton').mouseover(function() { $('#reloadWarningBackground').show(); }); 使用mouseout如下所示 $('#reloadButton').mouseover(function() { $('#reloadWarningBackground').show

我希望div
#reloadWarningBackground
仅在将鼠标悬停在按钮
#reloadButton
上时显示

这是我的密码:

$('#reloadButton').mouseover(function() {
    $('#reloadWarningBackground').show();
});

使用
mouseout
如下所示

$('#reloadButton').mouseover(function() {
    $('#reloadWarningBackground').show();
}).mouseout(function() {
    $('#reloadWarningBackground').hide();
})
更新

最好使用
mouseenter
,因为
mouseover
将重复执行

$('#reloadButton').mouseenter(function () {
    $('#reloadWarningBackground').show();
}).mouseleave(function () {
    $('#reloadWarningBackground').hide();
})

使用
mouseout
如下所示

$('#reloadButton').mouseover(function() {
    $('#reloadWarningBackground').show();
}).mouseout(function() {
    $('#reloadWarningBackground').hide();
})
更新

最好使用
mouseenter
,因为
mouseover
将重复执行

$('#reloadButton').mouseenter(function () {
    $('#reloadWarningBackground').show();
}).mouseleave(function () {
    $('#reloadWarningBackground').hide();
})

解决此问题的最简单也是最好的方法是使用toggle()

//html

<button id="reloadButton">
    Hover me
</button>
<div id="reloadWarningBackground" style="display:none;">
    <p>
        Hello this is me
    </p>
</div>

解决此问题的最简单和最好的方法是使用toggle()

//html

<button id="reloadButton">
    Hover me
</button>
<div id="reloadWarningBackground" style="display:none;">
    <p>
        Hello this is me
    </p>
</div>

您可以添加相应的HTML吗?您也可以添加相应的HTML吗