views:

34

answers:

1

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.

+1  A: 

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.

Pekka