How to asynchronously load CSS using jQuery?

后端 未结 8 1146
难免孤独
难免孤独 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-08 00:01

    This should work in IE:

    $("head").append("<link rel='stylesheet' type='text/css' href='/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css' />");
    
    0 讨论(0)
  • 2020-12-08 00:05
    $.get("path.to.css",function(data){
        $("head").append("<style>"+data+"</style>");
    });
    
    0 讨论(0)
提交回复
热议问题