Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Dynamically changing the id attribute of body tag (http://www.velocityreviews.com/forums/t880213-dynamically-changing-the-id-attribute-of-body-tag.html)

jdi 10-21-2004 06:11 PM

Dynamically changing the id attribute of body tag
 
I'm trying to change the value of the id attribute of the page's
<body> tag AFTER the tag is outputted.

i've two ways and both don't work

1)
document.getElementById("body").setAttribute("id", "hello");

2)
document.getElementsByTagName("body")[0].setAttribute("id","hello");

My page is as follows:

<html>
....
....
<body id="body">
....
</body>
</html>

Michael Winter 10-21-2004 06:12 PM

Re: Dynamically changing the id attribute of body tag
 
On 21 Oct 2004 11:11:03 -0700, jdi <a_muthiah@hotmail.com> wrote:

> I'm trying to change the value of the id attribute of the page's
> <body> tag AFTER the tag is outputted.


Might I ask why?

I can't see any reason why you might want to. The BODY element is unique
within a document, so why should it need a unique identifier.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

Lee 10-21-2004 06:44 PM

Re: Dynamically changing the id attribute of body tag
 
jdi said:
>
>I'm trying to change the value of the id attribute of the page's
><body> tag


I could well be overlooking something, but it seems to me that
when you find yourself in the situation of wanting to change the
id of *any* tag, it's time to reassess your approach.
If it's the id of the <body> tag, that seems even more likely.

What are you trying to accomplish?



All times are GMT. The time now is 08:52 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.