Yes, if all you're after is the Css properties, then just create the element
and analyze it with jQuery directly, without inserting it into your
document.

Sean


Gordon-35 wrote:
> 
> 
> That's what I have been doing up to now, it just feels really
> inelegant to be doing it that way.  I was hoping that there would be a
> way to get CSS properties of an element without having to put an
> example into the DOM first
> 
> On Aug 22, 2:53 pm, duma <[EMAIL PROTECTED]> wrote:
>> If you're after the Css-defined width and height parameters of an
>> element, it
>> seems to me you could just create the element and then do
>> $(elt).css("width") and $(elt).css("height").
>>
>> If you're after the actual rendered size of an element, then one way I
>> know
>> would work would be to set its display property to "none" (like others
>> have
>> suggested; $(elt).css("display", "none")), and then use the Dimension
>> plugin
>> to get its height and width.
>>
>> Take care!
>> Sean
>>
>>
>>
>> Gordon-35 wrote:
>>
>> > I have found that in some applications I need to know the size or
>> > other CSS attributes of elements that haven't been inserted int othe
>> > DOM yet.  So far I've been doing this by inserting an example of the
>> > element I need the size of into the DOM, selecting it, getting it's
>> > css() and then removing it again.
>>
>> > I really don't like this approach in the least though, because while
>> > it works it's inelegant, computationally expensive and in some
>> > browsers it can cause flickering.  The more elements you need to get
>> > parameters for, the more you need to add and to the DOM and the more
>> > flickering occurs. You can mitigate the flickering problem by making
>> > sure the elements you add to the dome have a css ('visibility',
>> > 'hidden') but that still leaves the other problems.
>>
>> > So basically, what I'm wondering is, if there is a CSS rule that
>> > defines an element's parameters, and if no examples of said element
>> > exist in the DOM yet, would it be possible to get the parameters
>> > direct from the stylesheet?
>>
>> --
>> View this message in
>> context:http://www.nabble.com/Get-size-for-elements-that-don%27t-exist-yet-tf...
>> Sent from the JQuery mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Get-size-for-elements-that-don%27t-exist-yet-tf4310553s15494.html#a12276765
Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to