Jump to content

Clearing Any Style Changing Made In Script


glopal

Recommended Posts

I have this javascript that runs on resize... <body onresize = "myfunction();">It grabs the "container" div by id, then looks at its offset width. If the width is less than 800, it loops through all the "img" divs ("img" is the class name, stfu, it works), and sets cssFloat = 'none';Basically, if you zoom in enough so that the floats are squeezing text and messing up headers, it breaks the float. And it works rather nicely.My question is: Can you revert changes made to style in javascript?Some explanation: On the else of "if(width<800)" I want it to reset all of the floats back to what they were originally (Some are left, some are right).I'm under the impression that going obj.style.cssFloat = 'none' is setting the inline style of that element... right? So if I were to go obj.style = "", wouldnt that clear the inline style, thus reverting back to the original style from the style sheet? I tried it, it doesnt appear to work.Any ideas?

Link to comment
Share on other sites

If you clear the property it uses the default value, whatever that is. Not the original value, but whatever the default for that property is defined as. You could use Firebug to verify, but as far as I know it doesn't store the original style information. If you wanted to keep track of that you would need to do it yourself.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...