Select Categories Below
Status: Closed Points: 50 Time: 20:47 - Sep 11, 2006
david
I want to create a DIV manually with javascript. How is that accomplished?
Categories:
Add Categories
When adding more than one category, separate them with commas.
Advertisement
Date:: Sep 12, 2006
Time:: 09:16
I found out myself: var newdiv = document.createElement('div'); var divIdName = 'testDiv'; newdiv.setAttribute('id',divIdName); newdiv.style.width = "300px"; newdiv.style.height = "300px"; newdiv.style.left = "300px"; newdiv.style.top = "300px"; newdiv.style.position = "absolute"; newdiv.style.background = "#00C"; newdiv.style.border = "4px solid #000"; newdiv.innerHTML = 'Test Div'; document.body.appendChild(newdiv);
multani.sarbjit
Time:: 11:58
good work...now give me your points...lol
jgivoni
Date:: Sep 13, 2006
Time:: 15:17
Ok, good enough david, but what I usually do is to define the DIV in the html code like this (example with some of your attributes): <div name="testDiv" id="divID" style="width: 300px; height: 300px; left: 300px; top: 300px; position: absolute; display: none"> Test Div </div> Note the "display: none" which hides it initially. When you want to show it, just execute document.getElementById("divID").style.display = ""; You can also create copies of it in javascript and - of course - hide it again. I think it makes it simpler to keep layout in the html file and only let javascript handle execution. Jakob
Date:: Sep 20, 2006
Time:: 11:25
Thanks, Jakob, but I needed the complete dynamic approach since it will be used on different html-pages without me being able to alter the html on beforehand.
Question Answered
This question has been closed, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.
Answer this Question
New User
Email:
Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address
Registered User
Username:
Password:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
Questions
How to make a 100% height and width, disable browser scrollbars like MSDN
How to determine whether element has scrollbar
Help with Mapquest API: Geocodes ignored, Kansas used instead
You have 100 characters to use
Rank
Expert
Points
1.
635
2.
540
3.
505
4.
330
5.
250
6.
7.
200
8.
175
9.
165
10.
125
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software Real Estate Postcards Marketing Fulfillment