嗨我想知道在哪里添加代码来延迟我的div的切换0.5秒 我刚开始使用javascript/jquery,但没有任何帮助,给JavaScript函数添加一个延迟
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//it is tied to this if it can help
<a onclick="toggle_visibility('section1_1_content');toggle_visibility('note1_1');"> <div id="help_tiem_section1_1" onclick="chngimg1()" onmouseover="this.style.cursor='pointer'">
<p1>TEST</p1><img src="down.png" height="10px" width="15px" id="imgplus1"/>
</div></a>
但是,我该如何改变它,以便当它改回显示时它不会延迟。 感谢Jcubic的快速响应。
https://developer.mozilla.org/en-US/docs/Web /API/WindowTimers.setTimeout – scniro
尝试使用谷歌.... – Ruddy
我把主题标题放到谷歌,想出了plen结果的类型。请在提问之前加上一点研究努力 – charlietfl