• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CSS combined names

 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I downloaded some code with CSS involved, when a table cell is clicked, the corresonding row and column are highlighted. the way to highlight is defined in CSS, suppose row highlight is assigned with classname: 'rowL' and column highlight is assigned with classname: 'colL'.

The intersection is defined as .rowL .colL {....}, so in the JavaScript, it highlights a row first (using row classname), then use a loop to highlight the column (using column classname), then the intersection table cell has two attributes at the same time.

I want to use CSS classname to determine the table cell value, but I have no idea to write if statement, I tried

if(cellattr.className == 'rowL' && cellattr.className == 'colL' )
if(cellattr.className == 'rowL && colL')

But none of them works.

Please help. Thanks.
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried if(cellattr.className == 'rowL colL')
it still does not work.
I found rowL is the row classname and colL is the column classname. When I use getElementsByTagName('TD'); I can only print classname for the columns, when I use getElementsByTagName('TR'); I only print out classname for the rows.

How could I do to found table cell classname belongs to .rowL .colL {....} ? Someone please help.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you consider looking at cellattr.className to see what its value actually was?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The class name is set to the TR and the TD seperately so of course when you read the TD it is only the one class. You would have to read the row and then the cell to get the combined className.

Eric
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I loop through TR first, then loop each TD in each row, then it works.
Thanks, guys.
reply
    Bookmark Topic Watch Topic
  • New Topic