How to asynchronously load CSS using jQuery?

后端 未结 8 1180
难免孤独
难免孤独 2020-12-07 23:22

I want to use jQuery to asynchronously load CSS for a document.

I found this sample, but this doesn\'t seem to work in IE:



        
8条回答
  •  情深已故
    2020-12-07 23:49

    The safe way is the old way...

    var stylesheet = document.createElement('link');
    stylesheet.href = '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css';
    stylesheet.rel = 'stylesheet';
    stylesheet.type = 'text/css';
    document.getElementsByTagName('head')[0].appendChild(stylesheet);
    

提交回复
热议问题