shenjw
shenjw

Reputation: 65

How to set CSS for the php script loaded by Jquery

I have a js function as below:

 function show() {
      $(document).ready(function() {
          $('#container').load('show_my_file.php');
          $('head').append( $('<link rel="stylesheet" type="text/css">').attr('href','show_my_file.css') );
      })
 }

This function is supposed to load the show_my_file.css to render #container (which now loads show_my_file.php), but it didn't work.

Does anybody how to how solve it? Thanks in advance.

Upvotes: 0

Views: 74

Answers (3)

responsiblevebri
responsiblevebri

Reputation: 29

$(document).ready(function() {
   function show() {
      $('#container').load('show_my_file.php');
      $('head').append( $('<link rel="stylesheet" type="text/css">').attr('href','show_my_file.css') );
   }
});

Upvotes: 0

angoru
angoru

Reputation: 5949

the only thing i see wrong is the load(show_my_file.php); it should be

$('#container').load('show_my_file.php');

it worked with for me.

Upvotes: 1

BlackPearl
BlackPearl

Reputation: 2795

Try this

  $('#container').load("show_my_file.php");

The file or path to the file should be in quote " "

Upvotes: 0

Related Questions