By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,767 Members | 1,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,767 IT Pros & Developers. It's quick & easy.

create an element on fly and add it to DOM

dmjpro
100+
P: 2,476
i was able to create an element using createelemnet and add it to body.
and it displayed properly......
but i could not access it using document.all.element_name...
that meand it is added to DOM ..
how can i do it..
plz send me code,,,,,,,,,,,,,,,,,,,,,thankssssssss
Feb 2 '07 #1
Share this Question
Share on Google+
3 Replies

acoder
Expert Mod 15k+
P: 16,027
document.all is IE-specific and very old. All modern browsers since 1998 support document.getElementById. So set an id when you create the element, then use:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(elementID)
to access the element where elementID is the id of your element.
Feb 2 '07 #2

dmjpro
100+
P: 2,476
thaaaaaaaaannnnnnnkssssssssssss for ur reply..........
ok it is now working .......................
Feb 3 '07 #3

acoder
Expert Mod 15k+
P: 16,027
No problem, you're welcome. Glad you got it working.
Feb 3 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.