javascript - 使用 onmouseover/onmouseout 更改可见性

标签 javascript html css onmouseout

我正在尝试通过 onmouseover 事件使 img 消失,然后我希望该 img 通过 onmouseout 事件重新出现这是我目前所拥有的:

<body>
    <h1>Catch the Easter Bunny to get your egg!</h1>
    <img src="images/rabbit.png" id="rabbit1" onmouseover=""
         onmouseout="show(this);" alt="Catch the rabbit"/>
    <img src="images/rabbit.png" id="rabbit2" onmouseover="hide(this);"
         onmouseout="show(this);" alt="Catch the rabbit"/>
    <img src="images/rabbit.png" id="rabbit3" onmouseover="hide(this)" alt="Catch the rabbit"/>
    <img src="images/rabbit.png" id="rabbit4" onmouseover="hide(this)" alt="Catch the rabbit"/>
    <h2 id="noeggs">No Easter Eggs for You</h2>
    <h2 id="yousuck">Humans suck!!!</h2>
</body>

var count = 0;

function hide(node) {
    count += 1;
    node.style.visibility = 'hidden';
}

function show(node) {
    node.style.visibility = 'visible';
}

最佳答案

尝试使用不透明度

node.style.opacity=0;

node.style.display='none';

关于javascript - 使用 onmouseover/onmouseout 更改可见性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16638932/

相关文章:

javascript - ember.js 访问计算属性中的每个上下文

javascript - ExtJS 5 工具提示位置

javascript - 设置 node.outerHTML 不会执行任何操作

php - 页面加载后平滑滚动到 div,而不是直接滚动

html - 在 OpenStreetMap 中获取城市的地理坐标

html - Bootstrap 3 - 垂直对齐输入组按钮和表单时出现问题

html - 页脚 html 也显示在下方

javascript - 是否可以使用固定高度的全宽 JSSOR slider ?

css - 如何使用 CSS 并排对齐三个图像

CSS - 通过悬停改变图像,就像这样!