我有下面的代码: 我需要做的是能够单击正下方的 Div,完成后 #info_page div 将在屏幕中间显示几秒钟。就像一个对话框,但只是一个带有计时器的简单 jquery temp show() ? 这可能吗?
当前代码如下。
<div onclick="show_info_box">Click to get message</div>
<div id="info_box" style="display:none">
<span class="custom info">
<img src="info.png" alt="info" height="48" width="48" />
<em>Information</em>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</span>
</div>
最佳答案
您需要在 onclick 代码中将 show_info_box 更改为 show_info_box(),函数如下...
function show_info_box() {
$("#info_box").show();
setTimeout(function() {
$("#info_box").hide();
}, 5000);
}
如果您愿意,您可以更改 fadeIn() 和 fadeOut() 的显示和隐藏以获得更好的外观。
关于javascript - 点击Div获取信息框几秒钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8758506/