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

Posted by user356981 on Stack Overflow See other posts from Stack Overflow or by user356981
Published on 2010-06-10T22:47:40Z Indexed on 2010/06/10 22:52 UTC
Read the original article Hit count: 121

Filed under:
|
|
|

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:

  $('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.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX