开发者

how to format (css) data loaded with $.load or $.get or $.ajax?

I need to load a piece of content html when an link in a menu is clicked; once loaded, the css format is not working properly, how do I re-format (re-styling via css) the loaded code? My code is:

开发者_Python百科
  $('a', mainMenu).click(function() {
     ref = this.href; 

     $('#content').load(ref + ' #content' function() {
        url = '../css/jquery-ui-1.8.2.custom.css';                

        //styling here
        if (document.createStyleSheet) document.createStyleSheet(url);
        else $('<link rel="stylesheet" type="text/css" href="'+url+'"/>').appendTo('head');

     });
   })

is it another way to load and re-style html (plugins perhaps)? thanks in adv'n.


If you don't want to specifically load a style sheet dynamically, there should be no need to re-format: If a newly loaded element is not styled correctly, there is something wrong in the CSS definition. Firebug's right click > "Inspect element" function is a mighty help to find out what goes wrong, and why a style doesn't get applied.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜