change css link and wait till new css is loaded

前端 未结 6 529
南笙
南笙 2020-12-17 22:48

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

thanks for a

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-17 23:21

    Try this man: http://forum.jquery.com/topic/loading-stylesheets-on-the-fly

    or : http://www.rickardnilsson.net/post/2008/08/02/Applying-stylesheets-dynamically-with-jQuery.aspx or Changing a stylesheet using jQuery

    Hope it fits the cause :)

    Code

    var link = $("");
    link.attr({
            type: 'text/css',
            rel: 'stylesheet',
            href: 
    });
    $("head").append( link ); 
    

提交回复
热议问题