SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calling CSS in Javascript

    in HTML you can call CSS

    Code:
    <head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    
    <tr><td class="cssHere">Display</td></tr>
    can you even call CSS in javascript?
    Code:
    document.writeln("<tr><td class="cssHere">" + Display + "</td></tr>");
    if so how do you even call the "style.css"

    thanks

  2. #2
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    document.write('<style>#id { display:none }</style>');

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    huh...

    Code:
    document.write('<style>#id { display:none }</style>');
    what is #id
    does this mean I can NOT call a .css file?

  4. #4
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Yes you can call a CSS link. Just put it in there in place of what I put.

  5. #5
    SitePoint Addict bronze trophy AllanP's Avatar
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    298
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    As an example, in your CSS page you might have:
    .sml { font-size:12px; color:#F00; }

    In your document you can write
    document.writeln("<tr><td class="sml">" + Display + "</td></tr>");

    and the text in Display will be 12px, red when the page renders.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •