页面加载后如何加载图像? [英] How to load images after page loaded?

查看:77
本文介绍了页面加载后如何加载图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码:

            <script type="text/javascript">
                $(document).ready(function(){
                    var id = 'i1';
                    var image = new Image();
                    image.src = 'http://url_to_my_image';
                    image.onload = function(){
                        $('#m' + id).attr('src',image.src);
                        $('#m' + id).show();
                    };
                  });

            </script>
            <ul style="list-style: none; margin: 0px; padding: 0px;">
                <li id="i1" style="display: inline;">
                    <div style="background-color: #bbb; width:768px;height:1024px;"><div style="margin-top:505px; margin-left: 370px; font-size: 24px; font-family: Arial, sans-serif; color: #333;">Load...</div></div>
                    <img src="" id="#mi1" style="display: hidden;" />
                </li>
            </ul>

但这不起作用.我要显示所有带有文本正在加载..."的空页面,并在加载图像页面后将其插入到相关的img元素中.

But this not work. I want to display all empty pages with text "Loading..." and after load image page insert it to the relevant img element.

对不起,我的英语不好...

Sorry for my terrible english...

推荐答案

尝试一下:

$("#m"+id).load("//your link");

您可以在以下内容上了解更多信息: api.jquery.com/load/

You can read more on this on: api.jquery.com/load/

这篇关于页面加载后如何加载图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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