Bart said:
Thomas said:
(e-mail address removed) 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.