Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8401997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:56:37+00:00 2026-06-09T21:56:37+00:00

I am loading a CSS stylesheet after page load with this code: $("head").append($("<link>", {

  • 0

I am loading a CSS stylesheet after page load with this code:

$("head").append($("<link>", {
    rel: "stylesheet",
    href: 'http://cdn.sstatic.net/stackoverflow/all.css',
    type: "text/css"
}));

Although this works fine (i.e. elements with classes from the newly added stylesheet are properly decorated), I am unable to query the CSS properties from that stylesheet using jQuery: I have created a jsFiddle to show the problem

How can I (ideally with jQuery) lookup the CSS properties of elements which classes correspond to CSS stylesheets added after page load?

PS: I am experiencing the issue with Firefox 14.0.1 but not with Chrome 21.0.1180.79.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:56:37+00:00Added an answer on June 9, 2026 at 9:56 pm

    If you do your console.log() calls in a “load” handler, it works fine:

    $("head").append($("<link>", {
        rel: "stylesheet",
        href: 'http://cdn.sstatic.net/stackoverflow/all.css',
        type: "text/css",
        load: function() {
          console.log($('#test1').css('color'));
          console.log($('#test2').css('color'));
          console.log($('#test3').css('color'));
          console.log($('#test4').css('color'));    
          }
      }));
    

    Fiddle, updated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to append a css file using $('head').append('<link rel=stylesheet href=style2.css type=text/css />');
I load css var ss = document.createElement(link); var url = 'http://site.ru/style.css'; ss.setAttribute(rel, stylesheet); ss.setAttribute(type,
<html> <head> <link href=http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css rel=stylesheet type=text/css/> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js></script> <script src=http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js></script> <% String str =Ravi;
Here is 3 css file (one is only for IE) <link rel=stylesheet href=css/blueprint/screen.css type=text/css
function switchTemplate(stylePath){ var ns = $('<link>', { href: stylePath, id: 'themeStyle', type: 'text/css', rel:
Possible Duplicate: Css and javascript Not Loading in rewrite rule After using only rewrite
Let's say we have an HTML page with a single stylesheet <link> . How
I come to next problem after this post . After loading data, gray overlay
Radiant::loadCSS = (fn, scope) -> head = document.getElementsByTagName(head)[0] link = document.createElement(link) link.setAttribute href, /
My cakephp is not loading any css,js. i uncommented the line Configure::write('App.baseUrl',env('SCRIPT_NAME')); in core.php.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.