更改css链接并等待,直到加载新的css [英] change css link and wait till new css is loaded

查看:153
本文介绍了更改css链接并等待,直到加载新的css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以更改加载的文档的样式表链接,然后等待新的css加载,然后运行适当的js代码

I wonder whether it's possible to change stylesheet link of the loaded document, then wait till the new css is loaded, and then run appropriate js code

感谢任何建议

推荐答案

html:

<link id="mystylesheet" href="/path/to/css.css" />

代码:

$("#mystylesheet").load(function(){
  //Your javascript
}).attr("href", "/new/path/to/css.css");

这将替换当前的CSS, code> .load()处理程序。

This will replace your current CSS, and execute any code within the .load() handler after the new CSS file has been fetched.

这篇关于更改css链接并等待,直到加载新的css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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