[Javascript] how to refer to (x)html elements

Chris Tifer christ at saeweb.com
Thu Nov 13 12:26:47 CST 2003


I don't think anyone's arguing that IDs are indeed a standard in CSS, or
even that they're standard in DHTML. What we're trying to say is that IDs
should be unique when being used to reference items. If you're going to
handle one instance, use an ID. If you're going to handle a group of
instances, use a class.

Chris Tifer
http://emailajoke.com



----- Original Message ----- 
From: "David Lovering" <dlovering at gazos.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Thursday, November 13, 2003 12:09 PM
Subject: Re: [Javascript] how to refer to (x)html elements


> Hmmm... I might refer you to section 5.9 of the URL
>
> http://www.w3.org/TR/REC-CSS2/selector.html
>
> The use of ID is again employed (as I suggested) as a CSS2 standard.  I
> believe the w3 standards group is the same one that backed the HTML
standard
> (and by extension the JavaScript usage of the id header).  I don't believe
> they are in the practice of promoting nonsense, although I could be
> mistaken.
>
> Now for the peace offering -- I AGREE with you; the only meaningful role
for
> "id" is as a one-to-one and onto identification for DOM objects.  The pity
> is that the CSS folks didn't pick something other than "ID" as the handle
to
> hang all this other stuff off of.  Also, the practice of quoting the HTML
id
> string and not quoting the CSS id strikes me as syntactic heresy of the
> highest order.
>
> The fact that this functionality closely matches the use of "CLASS"
further
> complicates things.
>
> Ah well, I've said my piece.
>
> -- Dave Lovering
>
>
> ----- Original Message ----- 
> From: "Hassan Schroeder" <hassan at webtuitive.com>
> To: "[JavaScript List]" <javascript at LaTech.edu>
> Sent: Thursday, November 13, 2003 7:38 AM
> Subject: Re: [Javascript] how to refer to (x)html elements
>
>
> > David Lovering wrote:
> >
> > > The real problem with "id" in HTML (and correspondingly in JavaScript)
> is
> > > that it tries to do too many things.
> >
> > <non-standards-compliant example removed/>
> >
> > Nonsense. ID does one thing -- it identifies a *single* element.
> >
> > And if you ignore the standard, and it *seems* to work -- so what?
> > You ran with scissors and didn't poke your eye out, you went 65mph
> > in a 35 zone and didn't get a ticket. So what?
> >
> > The standard is unambiguous. ID must be unique within a document.
> >
> > As Roger points out, getElement*s*ByTagName, plural, returns an
> > array; getElementById, singular, does not. A quick search turns up
> > this good snippet on the DOM:
> >
> > /* source: <http://xml.apache.org/xalan-j/apidocs/index.html> */
> >
> >    org.w3c.dom
> >      Interface Document  extends org.w3c.dom.Node
> >
> >   getElementById
> >
> >      public Element getElementById(java.lang.String elementId)
> >
> >    Returns the Element whose ID is given by elementId. If no such
> >    element exists, returns null. Behavior is not defined if more
> >    than one element has this ID. ...
> >
> >    Parameters:
> >      elementId - The unique id value for an element.
> >    Returns:
> >      The matching element.
> >    Since:
> >      DOM Level 2
> >
> > "Behavior is not defined" kinda sums it up, eh? :-)
> >
> > FWIW!
> > -- 
> > Hassan Schroeder ----------------------------- hassan at webtuitive.com
> > Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com
> >
> >                            dream.  code.
> >
> >
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> >
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list