Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30393

Re: Using getElementsByName on a DIV ?

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Using getElementsByName on a DIV ?
Date 2016-05-05 00:46 +0200
Organization PointedEars Software (PES)
Message-ID <5472957.EtlMkCADSI@PointedEars.de> (permalink)
References (11 earlier) <87shy86wo0.fsf@bsb.me.uk> <571fc489$1$5825$e4fe514c@news.xs4all.nl> <87a8kg6jz8.fsf@bsb.me.uk> <572080a7$0$5941$e4fe514c@news.xs4all.nl> <877ffi619z.fsf@bsb.me.uk>

Show all headers | View raw


Ben Bacarisse wrote:

> "R.Wieser" <address@not.available> writes:
   ^^         ^^^^^^^^^^^^^^^^^^^^^
WTF is this?  YTF are you people even talking to this guy?

> <snip>
>> Do I *really* need to spoon-feed the/a problem like in the below ?
> 
> No, you really have to provide an example document along with the code
> that doesn't work.
> 
>> [javascript]
>> Ancestor = this.parentNode;
>> aDescendants = Ancestor.getElementsByTagName("IMG");
>> // aDescendants = Ancestor.getElementsByName("foobar");
>> // aDescendants = Ancestor.getElementsByClassName("foobar");
>> // oDescendant = Ancestor.getElementByID("foobar");
                             ^^^^^^^^^^^^^^
>> [/javascript]
>>
>> I thought that should have been clear from my problem description.   But
>> I guess I expected too much ...

Enough niceties extended to the OP.  It takes a sharp axe to split a tough 
log¹:

This is not a free customer support forum; you are not a customer, and we 
are not the customer support team that needs to cater to your every whim in 
order to avoid losing you.  This is a technical newsgroup on software 
development for (aspiring) software developers.  Do your own homework and 
RTFFAQ, RTFM, STFW.  Or FOAD, luser.

> […]
> One thing is sure: if aDescendants is an element (as seems likely, but
> without a full example that's just a guess) the calls to
> getElementsByName and to getElementByID won't work.  These are methods
> that are part of the document interface, not the element interface.

getElementsByName() is a method of the *Document* (HTML5+) and 
*HTMLDocument* (W3C DOM Level 2 HTML, for [X]HTML < 5) interfaces only.

<http://www.w3.org/TR/2014/REC-html5-20141028/dom.html#the-document-object>

<http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-26809268>
<http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-011100101>
<https://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-745549614>
<https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-745549614>

There is no getElementByID() method in the W3C DOM, which is probably the 
reason why the call fails.  getElementById(), however (note the letter 
case), is and has always been a method of the *Document* interface.

<https://www.w3.org/TR/2015/REC-dom-20151119/#interface-nonelementparentnode>

<https://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#i-Document>
<https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#i-Document>

  [“Note: The getElementById() method is not on elements for compatibility 
   with older versions of jQuery. …” – WTF?]

___________
¹  Thanks to the people at dict.leo.org for the approximate translation of 
   the German original, „Auf einen groben Klotz gehört ein grober Keil“.
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-25 19:37 +0200
  Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-25 20:57 +0200
    Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-25 20:10 +0100
      Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-25 21:42 +0200
        Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-25 23:07 +0100
          Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 09:32 +0200
            Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-26 11:28 +0100
              Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 14:52 +0200
                Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-26 14:40 +0100
                Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 18:37 +0200
                Re: Using getElementsByName on a DIV ? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-04-26 19:12 +0200
                Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 20:44 +0200
                Re: Using getElementsByName on a DIV ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-26 19:17 +0200
                Re: Using getElementsByName on a DIV ? Stefan Weiss <krewecherl@gmail.com> - 2016-04-26 19:56 +0200
                Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 22:11 +0200
                Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-26 19:40 +0100
                Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 21:43 +0200
                Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-27 00:14 +0100
                Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-27 11:05 +0200
                Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-28 01:10 +0100
                Re: Using getElementsByName on a DIV ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-05 00:46 +0200
                Re: Using getElementsByName on a DIV ? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-05-06 12:56 +0200
                Re: Using getElementsByName on a DIV ? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-06 05:14 -0700
                Re: Using getElementsByName on a DIV ? John Harris <niam@jghnorth.org.uk.invalid> - 2016-05-05 14:36 +0100
                Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 20:38 +0200
        Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 08:57 +0200
  Re: Using getElementsByName on a DIV ? Stefan Weiss <krewecherl@gmail.com> - 2016-04-25 23:41 +0200
    Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 08:59 +0200
  Re: Using getElementsByName on a DIV ? JJ <jj4public@vfemail.net> - 2016-04-26 19:03 +0700
    Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 14:56 +0200
    Re: Using getElementsByName on a DIV ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-26 20:13 +0200
      Re: Using getElementsByName on a DIV ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-26 20:19 +0200
  Re: Using getElementsByName on a DIV ? Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-04-26 23:30 +0100
    Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-27 09:29 +0200
    Re: Using getElementsByName on a DIV ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-04-27 10:34 +0200
    Re: Using getElementsByName on a DIV ? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-04 19:04 -0700

csiph-web