JavaScript - 启动时隐藏Div(加载) [英] JavaScript - Hide a Div at startup (load)

查看:123
本文介绍了JavaScript - 启动时隐藏Div(加载)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的php页面中有一个div,它在页面加载后使用jQuery来隐藏它。但是有没有办法从loadup的开始就隐藏它?



我之所以问这个问题,是因为在短暂的时间内,您可以在页面显示时看到div加载,然后在页面完全加载时隐藏。



它看起来不专业。



只是想知道是否有是解决这个问题的方法吗?



谢谢 使用css样式隐藏div。

  #selector {display:none; } 

或者像下面这样使用它,

CSS:

  .hidden {display:none; } 

HTML

 < div id =blahclass =hidden><! -  div content  - >< / div> 

和jQuery

  $(function(){
$('#blah')。removeClass('hidden');
});


I have a div in my php page that uses jQuery to hide it once the page has loaded. But is there a way to hide it from the very start of loadup?

The reason I ask is because for a brief second, you can see the div when the page is loading, and then hides when the page is fully loaded.

It looks unprofessional.

Just wondering if there is a way around this?

Thanks

解决方案

Use css style to hide the div.

#selector { display: none; }

or Use it like below,

CSS:

.hidden { display: none; }

HTML

<div id="blah" class="hidden"><!-- div content --></div>

and in jQuery

 $(function () {
     $('#blah').removeClass('hidden');
 });

这篇关于JavaScript - 启动时隐藏Div(加载)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆