Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   How to read the classname of the table header (http://www.velocityreviews.com/forums/t940156-how-to-read-the-classname-of-the-table-header.html)

Stefan Mueller 12-19-2009 11:08 PM

How to read the classname of the table header
 
I've several tables. The header row of each table looks like
<th class = "style_table1_header1">
<div class = "style_column1"
onMouseover = "alert(this.className)">
Header of Column 1 in Table 1
</div>
</th>

<th class = "style_table1_header2">
<div class = "style_column2"
onMouseover = "alert(this.className)">
Header of Column 2 in Table 1
</div>
</th>

...

If you move the mouse pointer over the first header in table 1 'alert
(this.className)' in the onMouseover event displays 'style_column1'.
I there also a way to display the classname of <th> (in this example
'style_table1_header1')?

RobG 12-20-2009 01:09 AM

Re: How to read the classname of the table header
 
On Dec 20, 9:08*am, Stefan Mueller <seekw...@yahoo.com> wrote:
> I've several tables. The header row of each table looks like
> * <th class = "style_table1_header1">
> * * <div class = "style_column1"
> * * * onMouseover = "alert(this.className)">
> * * * Header of Column 1 in Table 1
> * * </div>
> * </th>
>
> * <th class = "style_table1_header2">
> * * <div class = "style_column2"
> * * * onMouseover = "alert(this.className)">
> * * * Header of Column 2 in Table 1
> * * </div>
> * </th>
>
> * ...
>
> If you move the mouse pointer over the first header in table 1 'alert
> (this.className)' in the onMouseover event displays 'style_column1'.
> I there also a way to display the classname of <th> (in this example
> 'style_table1_header1')?


The trivial answer is:

alert(this.parentNode.className);

But there may be more to your question than you've posted. You can
also put a listener on the th of course, but I suspect you don't want
to do that.


--
Rob

Stefan Mueller 12-20-2009 02:45 AM

Re: How to read the classname of the table header
 
Rob, that's it!
I haven't thought that it will be so easy. Great!

Many thanks for your help.

Evertjan. 12-20-2009 10:01 AM

Re: How to read the classname of the table header
 
RobG wrote on 20 dec 2009 in comp.lang.javascript:

> On Dec 20, 9:08˙am, Stefan Mueller <seekw...@yahoo.com> wrote:
>> I've several tables. The header row of each table looks like
>> ˙ <th class = "style_table1_header1">
>> ˙ ˙ <div class = "style_column1"
>> ˙ ˙ ˙ onMouseover = "alert(this.className)">
>> ˙ ˙ ˙ Header of Column 1 in Table 1
>> ˙ ˙ </div>
>> ˙ </th>
>>
>> ˙ <th class = "style_table1_header2">
>> ˙ ˙ <div class = "style_column2"
>> ˙ ˙ ˙ onMouseover = "alert(this.className)">
>> ˙ ˙ ˙ Header of Column 2 in Table 1
>> ˙ ˙ </div>
>> ˙ </th>
>>
>> ˙ ...
>>
>> If you move the mouse pointer over the first header in table 1 'alert
>> (this.className)' in the onMouseover event displays 'style_column1'.
>> I there also a way to display the classname of <th> (in this example
>> 'style_table1_header1')?

>
> The trivial answer is:
>
> alert(this.parentNode.className);
>
> But there may be more to your question than you've posted. You can
> also put a listener on the th of course, but I suspect you don't want
> to do that.
>


If the class name is realy specific to one element

>> <th class = "style_table1_header1">


better use an id

<th id = "my_table1_header1">

and

#my_table1_header1 {..}



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


All times are GMT. The time now is 05:59 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.