Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to read the classname of the table header

Reply
Thread Tools

How to read the classname of the table header

 
 
Stefan Mueller
Guest
Posts: n/a
 
      12-19-2009
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')?
 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      12-20-2009
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
 
Reply With Quote
 
 
 
 
Stefan Mueller
Guest
Posts: n/a
 
      12-20-2009
Rob, that's it!
I haven't thought that it will be so easy. Great!

Many thanks for your help.
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      12-20-2009
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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Header files with "header.h" or <header.h> ?? mlt C++ 2 01-31-2009 02:54 PM
CSS: "tagname.classname" or ".classname" Ante Perkovic Javascript 2 12-25-2003 03:02 AM
Is `new classname' the same as `new classname()' ? Hongzheng Wang C++ 32 12-05-2003 05:29 PM
classname::classname a type ? Oliver S. C++ 1 09-11-2003 07:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57