基于jquery的载入提示

一直想找个好的loading用在网站载入慢的时候提示提示,不用干等着,不是滋味。Jquery可以很好的实现这一效果,在老外那找到这代码太爽了,简单易用实用。

在代码<head></head>里加入以下代码:

<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(window).load(function(){
    $("#loading").hide();
})
</script>

在里<body></body>加入以下代码:

<div id="loading">
Loading content, please wait..
<img src="loading.gif" alt="loading.." />
</div>

在里的这代码必须保证在网页载入的最前面。

接着是css代码:

#loading{
position:absolute;
width:300px;
top:0px;
left:50%;
margin-left:-150px;
text-align:center;
padding:7px 0 0 0;
font:bold 11px Arial, Helvetica, sans-serif;
}

一个基于jquery的loading效果就完成咯。

8 thoughts on “基于jquery的载入提示

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">