[jQuery] Re: How to get css object of one element?

2009-04-27 Thread Eric Garside

Using the jQuery object as an array ($('.selector')[0]) returns the
HTMLElement.

Using jQuery's eq function returns the jQuery object of the
HTMLElement at that position:

$('a').eq(0).css('color');

On Apr 27, 3:38 pm, Ngoc Bui buitrungngo...@gmail.com wrote:
 Hi all,

 I wonder how to get css object of ONE single element? Normally, with array
 of element we can do like this: $(“a”).css(“color”).  However, when I go
 through each element, this is not available: e.g. $(“a”)[0].css( “color”);

 Anyone knows how to get css properties of one single element please help me?

 Thanks in advance.

 ~Ngoc


[jQuery] Re: How to get css object of one element?

2009-04-27 Thread Karl Swedberg
It depends on which one you want, but there are a number of selectors  
available. For example:


$('a:first').css('color');
$('a:last').css('color');
$('a:eq(2)').css('color');

More info here: http://docs.jquery.com/Selectors

--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Apr 27, 2009, at 3:38 PM, Ngoc Bui wrote:


Hi all,

I wonder how to get css object of ONE single element? Normally, with  
array of element we can do like this: $(“a”).css(“color”).  However,  
when I go through each element, this is not available: e.g. $(“a”) 
[0].css( “color”);


Anyone knows how to get css properties of one single element please  
help me?


Thanks in advance.
~Ngoc