SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    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)

    I need a unique way of adding css with js?

    Hello I am aware of most of the ways to do this. But none seem to fit my needs on this one. Usually I use jquery to add the class of "js" to the HTML and use html.js {yada} but its too slow in this circumstance. I am loading a image 5 seconds after page load with jquery. But using the html method of adding display none the image flashes briefly. I imagine if I were to put all the jquery at the top then it may not happen. Buts that's not an option. Currently I just have display none in the css. But that does not degrade well. The only way I can think of is to use documentwrite to insert display none and place this above my css links. This would work but its messy and I have to go in and add it to all my pages (I don't trust find and replace). Any other methods I'm not thinking of that would insert display none before the image loads on the page? Thanks!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,678
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by EricWatson View Post
    Any other methods I'm not thinking of that would insert display none before the image loads on the page? Thanks!
    You could add the images to a container that is already hidden? It doesn't even have to be attached to the DOM, and can just be a document fragment.
    You could then hide the images and then move them to where they need to go.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •