1. <legend id='ENSyn'><style id='ENSyn'><dir id='ENSyn'><q id='ENSyn'></q></dir></style></legend>
    <tfoot id='ENSyn'></tfoot>
      <bdo id='ENSyn'></bdo><ul id='ENSyn'></ul>

    1. <small id='ENSyn'></small><noframes id='ENSyn'>

    2. <i id='ENSyn'><tr id='ENSyn'><dt id='ENSyn'><q id='ENSyn'><span id='ENSyn'><b id='ENSyn'><form id='ENSyn'><ins id='ENSyn'></ins><ul id='ENSyn'></ul><sub id='ENSyn'></sub></form><legend id='ENSyn'></legend><bdo id='ENSyn'><pre id='ENSyn'><center id='ENSyn'></center></pre></bdo></b><th id='ENSyn'></th></span></q></dt></tr></i><div id='ENSyn'><tfoot id='ENSyn'></tfoot><dl id='ENSyn'><fieldset id='ENSyn'></fieldset></dl></div>

      jQuery 追加 CSS 文件并等待加载?

      时间:2023-10-20
      <i id='LYWeG'><tr id='LYWeG'><dt id='LYWeG'><q id='LYWeG'><span id='LYWeG'><b id='LYWeG'><form id='LYWeG'><ins id='LYWeG'></ins><ul id='LYWeG'></ul><sub id='LYWeG'></sub></form><legend id='LYWeG'></legend><bdo id='LYWeG'><pre id='LYWeG'><center id='LYWeG'></center></pre></bdo></b><th id='LYWeG'></th></span></q></dt></tr></i><div id='LYWeG'><tfoot id='LYWeG'></tfoot><dl id='LYWeG'><fieldset id='LYWeG'></fieldset></dl></div>
        <tbody id='LYWeG'></tbody>
      1. <small id='LYWeG'></small><noframes id='LYWeG'>

        1. <tfoot id='LYWeG'></tfoot>

          <legend id='LYWeG'><style id='LYWeG'><dir id='LYWeG'><q id='LYWeG'></q></dir></style></legend>
          • <bdo id='LYWeG'></bdo><ul id='LYWeG'></ul>
              • 本文介绍了jQuery 追加 CSS 文件并等待加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用

                $('head').append('<link rel="stylesheet" href="style2.css" type="text/css"/>');

                这很好用 - 但是,我有一些在添加 css 之后运行的函数,我想不出一种方法让这些函数等到这个文件完成加载?

                That works great - however, I have some functions that run AFTER the css has been added and I can't figure out a way for these to wait until this file has finished loading ?

                我该怎么做?

                推荐答案

                只需检查新 CSS 的规则之一何时应用即可:

                Just check when one of the rules of the new CSS has been applied:

                $('head').append('<link rel="stylesheet" href="http://cdn.sstatic.net/stackoverflow/all.css?v=d4a5c7ca0d4c" type="text/css" />');
                
                var fakeListener = setInterval(function(){
                    if($("body").css("text-align")=== "center"){
                        clearInterval(fakeListener)
                        // What you want to do after it loads
                    }
                },50)
                

                (这是一个工作示例)

                这篇关于jQuery 追加 CSS 文件并等待加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:jQuery Uniform Checkbox 不(取消)选中 下一篇:jQuery函数在append()之后没有响应

                相关文章

              • <tfoot id='HgWvz'></tfoot>

                <small id='HgWvz'></small><noframes id='HgWvz'>

              • <legend id='HgWvz'><style id='HgWvz'><dir id='HgWvz'><q id='HgWvz'></q></dir></style></legend>
                1. <i id='HgWvz'><tr id='HgWvz'><dt id='HgWvz'><q id='HgWvz'><span id='HgWvz'><b id='HgWvz'><form id='HgWvz'><ins id='HgWvz'></ins><ul id='HgWvz'></ul><sub id='HgWvz'></sub></form><legend id='HgWvz'></legend><bdo id='HgWvz'><pre id='HgWvz'><center id='HgWvz'></center></pre></bdo></b><th id='HgWvz'></th></span></q></dt></tr></i><div id='HgWvz'><tfoot id='HgWvz'></tfoot><dl id='HgWvz'><fieldset id='HgWvz'></fieldset></dl></div>

                      <bdo id='HgWvz'></bdo><ul id='HgWvz'></ul>