You are right, I created the element in the DOM and it worked fine. However I found this: http://www.javascriptkit.com/dhtmltutors/externalcss.shtml And it seems it's exactly what I was looking for in the first place, but I don't if I should use it as some browsers (though they are less used) do not support the styleSheets object and creating the element in the DOM and then remove it, probably works on most of them, I just don't like the solution cause it feels like a "work around" and what I really want, I can do it with document.styleSheets.
On Aug 7, 7:58 pm, "Dan G. Switzer, II" <[EMAIL PROTECTED]> wrote: > >I'm trying to do that due to this issue: > >http://groups.google.com/group/jquery- > >en/browse_thread/thread/0a3630dc90b2c10b/1026fc07b5cd587f?#1026fc07b5cd587f > > >If you have any other and better solution, I'm all hears :) > > >You say the DOM element does not exist, but isn't that what clone is > >supposed to do? I though I was cloning an element in the DOM and then > >changing it's class... > > No, it exists as an element stored in a variable--but not an actual item in > the current DOM tree. > > It would be the same as doing: > > var el = document.createElement("a"); > > The above is an element, but it doesn't currently exist in the DOM until I > programmatically place in the DOM: > > document.body.appendChild(el); > > My experience with IE is that certain aspects of an element can not be read > until it actually is placed in the DOM tree. This is usually related to > things that affect the visual state of the element (such as the color of the > text.) > > I believe this is because IE doesn't fully process elements that aren't > capable of being viewed. > > My guess is if you actually try adding the cloned item somewhere on the page > (using the $("body").append()) you could probably then read the color. > > If that does work, then it sounds like my suspicion may be correct and that > you might need to move the element to a DOM and then remove it when you're > done with it. > > -Dan