Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22704
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How do I best find the last anchor under a table with id=filer |
| Date | 2014-01-18 21:24 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <lberf9$to6$1@dont-email.me> (permalink) |
| References | <lbeh71$38c$1@dont-email.me> |
On Sat, 18 Jan 2014 19:29:44 +0100, Tony Johansson wrote:
> There is always only one td in each tr and there is always the anchor
> element in the td element So I must find the last anchor element in the
> table with id=filer ? What is the best way to do that in either
> javascript or jquery ?
Don't know about "best", and don't know about jquery.
In javascript there are several ways, including (untested):
var t,c,a,e;
t=document.getElementById("filer"); // table
c=t.rows[t.rows.length-1].cells[0]; // only cell in last row
a=c.getElementsByTagName("a"); // anchors in cell
e=a[a.length-1]; // last anchor
If there's only ever a single anchor in each cell:
var t,c,e;
t=document.getElementById("filer"); // table
c=t.rows[t.rows.length-1].cells[0]; // only cell in last row
e=c.getElementsByTagName("a")[0]; // only anchor in cell
Possibly quicker, possibly not, may depend on browser:
var a,e;
a=document.getElementById("filer").getElementsByTagName("a"); // anchors
in table
e=a[a.length-1]; // last anchor
--
Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How do I best find the last anchor under a table with id=filer "Tony Johansson" <johansson.andersson@telia.com> - 2014-01-18 19:29 +0100
Re: How do I best find the last anchor under a table with id=filer "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-18 20:28 +0100
Re: How do I best find the last anchor under a table with id=filer Danny <dann90038@gmail.com> - 2014-01-18 11:46 -0800
Re: How do I best find the last anchor under a table with id=filer Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-18 21:39 +0000
Re: How do I best find the last anchor under a table with id=filer Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-19 05:44 +0100
Re: How do I best find the last anchor under a table with id=filer Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-18 21:24 +0000
Re: How do I best find the last anchor under a table with id=filer Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-19 05:32 +0100
Re: How do I best find the last anchor under a table with id=filer John Harris <niam@jghnorth.org.uk.invalid> - 2014-01-20 15:34 +0000
Re: How do I best find the last anchor under a table with id=filer "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-20 16:38 +0100
Re: How do I best find the last anchor under a table with id=filer John Harris <niam@jghnorth.org.uk.invalid> - 2014-01-20 15:54 +0000
Re: How do I best find the last anchor under a table with id=filer RobG <rgqld@iinet.net.au> - 2014-01-19 16:40 +1000
Re: How do I best find the last anchor under a table with id=filer JJ <duh@nah.meh> - 2014-01-19 19:07 +0700
Re: How do I best find the last anchor under a table with id=filer Christoph Michael Becker <cmbecker69@arcor.de> - 2014-01-19 21:56 +0100
csiph-web