jquery 隐藏元素在页面加载时加载 1 秒
我正在使用 jquery 滑入滑出,加载时(大约 1 秒)出现在页面上,然后隐藏。我根本不想让它显示,我该怎么办?
我正在使用这段代码:
$(document).ready(function() {
// hides the slickbox as soon as the DOM is ready
// (a little sooner than page load)
$('#menucategory').hide();
// shows the slickbox on clicking the noted link
$('img.menu_class').click(function() {
$('#menucategory').show('slow');
return false;
});
// hides the slickbox on clicking the noted link
$('a#hidecategory').click(function() {
$('#menucategory').hide('slow');
return false;
});
});
I am using a jquery slide in slide out that appears on the page when loading (about 1 second) then is hidden. I dont want it to show at all, how can i do this?
I am using this code:
$(document).ready(function() {
// hides the slickbox as soon as the DOM is ready
// (a little sooner than page load)
$('#menucategory').hide();
// shows the slickbox on clicking the noted link
$('img.menu_class').click(function() {
$('#menucategory').show('slow');
return false;
});
// hides the slickbox on clicking the noted link
$('a#hidecategory').click(function() {
$('#menucategory').hide('slow');
return false;
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
只需通过 css 默认隐藏 #menucateogry:
那么您所需要的就是以下内容:
编辑:原因是,由于您正在执行 $(document).ready(),因此您的 hide() 代码实际上不会运行,直到图像加载完成。
Just make the #menucateogry hidden by default via css:
Then all you need is the following:
EDIT: The reason is, since you are doing $(document).ready(), your hide() code won't actually run until the image is done loading.
嗯,只有在 DOM 加载后,您的事件才会触发。最好用 CSS 隐藏它。将其放在页面顶部或样式表中
Well your events will fire only once the DOM has loaded. Better to just hide it with CSS. Put this at the top of your page or in the stylesheet
尝试将 css 样式元素放在 #menucategory display:none 上
Try putting the css style element on #menucategory display:none
先写css
然后写下面的代码
});
first write css
then write below code
});