Re: change the ID dynamically



Thomas 'PointedEars' Lahn wrote:

Bart Van der Donck wrote:

Thomas 'PointedEars' Lahn wrote:
mayurkoul2002@xxxxxxxxx wrote:
[assign ID attribute dynamically to the html tags]

That is as impossible as your posting "style".

Why would that be impossible ?

<html>
<body>
<p>content</p>
<script language="javascript" type="text/javascript">

The `language' attribute is deprecated long since, and your markup
is not Valid; especially, the missing DOCTYPE declaration triggers
Quirks Mode, which can change DOM behavior.

document.getElementsByTagName('p')[0].setAttribute('id','myID');
alert(document.getElementById('myID').innerHTML);
</script>
</body>
</html>

That is setting the attribute, not changing it. Note the Subject header.
Furthermore:

- This requires other DOM methods that may not be available.

- It is known to be not possible for some elements in some DOMs
(IIRC there are issues in the IE DOM).

- setAttribute() implementations are known to be buggy.

Hmmmm, that Asperger-smell in the morning :-)

--
Bart

.



Relevant Pages

  • Re: change the ID dynamically
    ... The `language' attribute is deprecated long since, ... This requires other DOM methods that may not be available. ... In the First World War, ...
    (comp.lang.javascript)
  • Re: kb9rqz musings
    ... obviously not as you keep posting you sick shit here ... (tend to be a a bit more sub than Dom) ... Dom with other Males, but has only been Dom with women, and would really ...
    (rec.radio.amateur.policy)
  • Re: huge XML files, XSLT memory problems, Java & SAX...
    ... newsgroup before posting, but I didn't find what I thought I might. ... XSLT requires a DOM to exist, so if I wish to not write my own XSLT ...
    (comp.text.xml)
  • Re: Domsez - Amy Winehouse goes Back to Smack
    ... doubt the lamest Youtube clip I've seen. ... Dom just has personal problems. ... For someone who only just started posting a few days ago, ...
    (uk.media.tv.misc)
  • Re: change the ID dynamically
    ... That is as impossible as your posting "style". ... which can change DOM behavior. ... This requires other DOM methods that may not be available. ...
    (comp.lang.javascript)