[BNM] jquery traversing help!
Jason Bailey
j.bailey at sussex.ac.uk
Wed Oct 1 11:39:56 BST 2008
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
More information about the BNMlist
mailing list. Powered by Wessex Networks