Adam Posted December 2, 2008 Share Posted December 2, 2008 Pretty much says it all in the name. I can't simply use getElementById() because I won't know what the IDs will be. I've tried using childNodes but with no look so far - also tried firstChild. This doesn't require compliance with IE as I've already achieved what I want in IE.. Can anybody offer any help? Cheers! Adam Quote Link to comment https://forums.phpfreaks.com/topic/135187-getting-the-child-anchor-element-of-a-table-cell/ Share on other sites More sharing options...
xtopolis Posted December 2, 2008 Share Posted December 2, 2008 This book: Pro Javascript Techniques, has a lot of good traversing functions. http://jspro.org/code/ [Download All Code] I'm missing one function from here that you need: prevSibling(), but I don't want to search through his code to find it. Here are the important parts, you just need to search his code for "prevSibling"() function, and copy it. Then you should be able to use these in combination to get what you want. function prev( elem ) { do { elem = elem.previousSibling; } while ( elem && elem.nodeType != 1 ); return elem; } //------------------------------------------------------------------------------- function next( elem ) { do { elem = elem.nextSibling; } while ( elem && elem.nodeType != 1 ); return elem; } //------------------------------------------------------------------------------- function first( elem ) { elem = elem.firstChild; return elem && elem.nodeType != 1 ? nextSibling( elem ) : elem; } //------------------------------------------------------------------------------- function last( elem ) { elem = elem.lastChild; return elem && elem.nodeType != 1 ? prevSibling( elem ) : elem; } //------------------------------------------------------------------------------- function parent( elem, num ) { num = num || 1; for ( var i = 0; i < num; i++ ) if ( elem != null ) elem = elem.parentNode; return elem; } Quote Link to comment https://forums.phpfreaks.com/topic/135187-getting-the-child-anchor-element-of-a-table-cell/#findComment-704098 Share on other sites More sharing options...
Adam Posted December 4, 2008 Author Share Posted December 4, 2008 Great stuff, thanks! I shall have a play around shortly.. Adam Quote Link to comment https://forums.phpfreaks.com/topic/135187-getting-the-child-anchor-element-of-a-table-cell/#findComment-705914 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.