Re: change the ID dynamically
- From: Randy Webb <HikksNotAtHome@xxxxxxx>
- Date: Wed, 31 May 2006 11:06:01 -0400
Thomas 'PointedEars' Lahn said the following on 5/31/2006 8:26 AM:
Bart Van der Donck wrote:
Thomas 'PointedEars' Lahn wrote:mayurkoul2002@xxxxxxxxx wrote:Why would that be impossible ?[assign ID attribute dynamically to the html tags]That is as impossible as your posting "style".
<html>
<body>
<p>content</p>
<script language="javascript" type="text/javascript">
The `language' attribute is deprecated long since, and your markup
is not Valid;
Semi-valid point but irrelevant to the rebuttal to your assertion that it was impossible.
especially, the missing DOCTYPE declaration triggers Quirks Mode, which can change DOM behavior.
Only in IE and in this case it makes no difference.
document.getElementsByTagName('p')[0].setAttribute('id','myID');
document.getElementById('p')[0].id = 'newID';
alert(document.getElementById('myID').innerHTML);
</script>
</body>
</html>
That is setting the attribute, not changing it. Note the Subject header.
Yoohoo, dimwit, think about it. An element has an ID. You "set" the ID, then alert that elements ID. It will give you the new ID. That is changing the ID. You can be as pedantic as you want but the ID got changed.
Furthermore:
- This requires other DOM methods that may not be available.
Only if the user is using an antiquated anti-social browser.
- It is known to be not possible for some elements in some DOMs
(IIRC there are issues in the IE DOM).
Such as?
- setAttribute() implementations are known to be buggy.
Then you offer a better alternative. Or, preferably, you STFU and move on.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
.
- References:
- change the ID dynamically
- From: mayurkoul2002
- Re: change the ID dynamically
- From: Thomas 'PointedEars' Lahn
- Re: change the ID dynamically
- From: Bart Van der Donck
- Re: change the ID dynamically
- From: Thomas 'PointedEars' Lahn
- change the ID dynamically
- Prev by Date: Re: tutorial on dynamic SID generation
- Next by Date: Re: Creating References To Strings
- Previous by thread: Re: change the ID dynamically
- Next by thread: Re: change the ID dynamically
- Index(es):