如何使某些东西先在javascript和jQuery中先加载 [英] How to make something load first before another in javascript and jquery

查看:75
本文介绍了如何使某些东西先在javascript和jQuery中先加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div,其中包含文本和背景图片.当我加载页面时,文本始终显示为1st(假设我的互联网连接速度较慢).如何在文本之前加载背景图片?能否请您同时给我jquery和javascript中的解决方案

I have a div with text in it and a background image. When I load the page the text always appear 1st(assume i have low speed internet connection). How can i make the background image load before text? Can You please give me solution in both jquery and javascript

推荐答案

中添加文本图片的onload事件处理程序.

注意:如果要继续使用带有背景图像的div标签而不是img标签,则必须在此答案以获取详细信息).

Note: If you want to keep using a div tag with a background image rather than an img tag, you'll have to add the text during the window.onload event (see this answer for the details).

这篇关于如何使某些东西先在javascript和jQuery中先加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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