[BNM] jquery traversing help!

wayne at codingvista.com wayne at codingvista.com
Wed Oct 1 11:41:07 BST 2008


Hey man

Tables are _for_ laying out data.

I'll read the rest now :)

W://

-----Original Message-----
From: bnmlist-bounces at brightonnewmedia.org
[mailto:bnmlist-bounces at brightonnewmedia.org] On Behalf Of Jason Bailey
Sent: 01 October 2008 11:40
To: brighton new media
Subject: [BNM] jquery traversing help!

Hello,

I'm trying to layout some data in a table (sorry any nice examples for a 
nice CSS table type layout). I'm using jquery to allow url to go off and 
bring back some data related to that row and place it next to the row. I'm 
assuming I need to build ids which include the row number so I can see 
which row has been clicked and where to display result (next to row).

I'm trying to get the id of a span tag in a table

e.g. I've got...
.....<td><a href="">I'm somewhere in here!</a></td><td><span 
id="myid1">test text</span></td>...

If I do:
 alert("xx"+$(this).parent().next().html()+"xx")  // xx to see if any 
spaces around it

I get: xx<span id="myid1">test text</span>xx
and
alert("xx"+$(this).parent().next().text()+"xx")  //gives xxtest textxx

So how do I dip into the above span tag and get the id attribute.

I was thinking something like
 alert($(this).parent().next().child().attr('id'))
would do it

Now thinking first child but am still emailing as I'm going a bit loopy 
with this traversing. Any tips on doing this better.
i.e. I'm creating id tags along the lines of id="id"+rownum and building a 
set of ids with a text and row number part so I can
1. See which row (many rows) has been selected
2. Display something new in the row.

Bit stuck
Thanks
Jason

-- 

BNM Subscribe/Unsubscribe:
http://www.brightonnewmedia.org/options/bnmlist

BNM powered by Wessex Networks:
http://www.wessexnetworks.com



More information about the BNMlist mailing list. Powered by Wessex Networks