🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.javascript
Article #50130

Niespójność JS?

#50130
From: zpk
Date: Sun, 13 Jun 2010 08:26
27 lines
1860 bytes
Bawię się ostatnio własnościami elementów, np:

<element id="xx" class="cc" bla="gg" />

jeżeli zidentyfikuję go np tak:
var el=document.getElementById('xx');

Zauważyłem, że można napisać:
if (el.id=='xx') ...

Ale już nie można
if (el.class=='cc') ...

tylko trzeba:
if (el.className=='cc') ...

A zupełnie nie można
if (el.bla=='gg') ...  //IE to rozumie

tylko trzeba aż:
if (el.attributes.getNamedItem("bla").value=='gg') ...

Z mojego punktu widzenia element ma atrybuty id, class i bla.
Dlaczego nie ma jednolitej interpretacji dotarcia do atrybutów?
A może jest tylko jeszcze do tego nie dotarłem ?

Pozdrawiam- Paweł Krzyżanowski
Technical Details
Message-ID: <ff30c9b5-86fa-42e1-87af-0af070f340d2@e5g2000yqn.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!feeder.erje.net!proxad.net!feeder1-2.proxad.net!74.125.46.134.MISMATCH!postnews.google.com!e5g2000yqn.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!feeder.erje.net!proxad.net!feeder1-2.proxad.net!74.125.46.134.MISMATCH!postnews.google.com!e5g2000yqn.googlegroups.com!not-for-mail
From: zpk <zpksoft@op.pl>
Newsgroups: pl.comp.lang.javascript
Subject: Niespójność JS?
Date: Sun, 13 Jun 2010 01:26:31 -0700 (PDT)
Organization: http://groups.google.com
Lines: 29
Message-ID: <ff30c9b5-86fa-42e1-87af-0af070f340d2@e5g2000yqn.googlegroups.com>
NNTP-Posting-Host: 83.15.210.85
Mime-Version: 1.0
X-Trace: posting.google.com 1276417591 24837 127.0.0.1 (13 Jun 2010 08:26:31 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 13 Jun 2010 08:26:31 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: e5g2000yqn.googlegroups.com; posting-host=83.15.210.85;  posting-account=8ND_mgoAAAD5J9y9fnaTB1Kcu7xKWk7Q
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1;  Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR  3.0.30729; Media Center PC 6.0),gzip(gfe)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit