Reply
What's my column index?
Old 01-03-2008, 07:08 PM What's my column index?
Experienced Talker

Posts: 35
Name: Andrew
I'm trying to make a bit of code that allows the user to select 1 item from each column in a table by turning it red or something. When another item in that column is clicked on, the red moves to that cell instead. What I want to do is (jQuery code):

$(":nth-child(" + myIndex + ")").removeClass("Selected");
$(this).addClass("Selected");

This works fine, except that I don't know how to get the column index of the cell on which I clicked.

I know I can get round this by looking at the parent's children and seeing which one is me, or by adding classes like "Col1" to each td, but I feel there should be a way to get the index of a child node (surely?). I spent a fair while looking but couldn't find anything useful. Am I missing something really obvious?
__________________
Pole Exercise - Pole dancing evolved
meloncholy is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 01-03-2008, 07:14 PM Re: What's my column index?
Experienced Talker

Posts: 35
Name: Andrew
Um, just to answer my own question, yes I was. (Why is it these solutions only appear just after posting a question?)

For cells only, we have this.cellIndex. I don't believe there's a general equivalent, though I'll probably find I'm wrong after clicking submit...
__________________
Pole Exercise - Pole dancing evolved
meloncholy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to What's my column index?
 

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11662 seconds with 13 queries