如何在div鼠标悬停上显示按钮 [英] How to show button on div mouse hover
本文介绍了如何在div鼠标悬停上显示按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在div悬停上显示按钮。
当我将鼠标悬停在div上然后按钮显示否则隐藏。
i want to show button on div hover. when i hover mouse on div then button show otherwise hide.
我的按钮在 divbutton
html
<div class="divbutton">
<button type="button" style="display: none;">Hello</button>
</div>
当我将鼠标悬停在div应该显示,但如何做,我不知道。
当我再次删除鼠标按钮时隐藏。
谢谢。
when I hover mouse on div it should show but how to do that i do not know. when I remove mouse button again hide. Thank you.
推荐答案
使用以下jQuery执行您的任务。
Use following jQuery to perform your task.
以下是 jsfiddle演示
$(document).ready(function () {
$(document).on('mouseenter', '.divbutton', function () {
$(this).find(":button").show();
}).on('mouseleave', '.divbutton', function () {
$(this).find(":button").hide();
});
});
这篇关于如何在div鼠标悬停上显示按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文