Select Categories Below
Status: Closed Points: 75 Time: 18:33 - Sep 13, 2006
jgivoni
For example, imagine I have an element like this: <div id="test" style="width: 100px; border-top: 1px solid black"/> Normally I can change the style dynamically like this: document.getElementById("test").style.width = "200px"; But, similarly, this doesn't work: document.getElementById("test").style.border-top = "2px solid green"; Apparantly, the hyphen (-) in the style attribute (border-top) is causing trouble (being interpreted as a minus). So what is the correct syntax in this case? Thanks, Jakob
Categories:
Add Categories
When adding more than one category, separate them with commas.
Advertisement
multani.sarbjit
Date:: Sep 14, 2006
Time:: 07:18
Hi Jakob, Try this document.getElementById("test").style: border-top: 2px solid green; Regards, Sarbjit
Anpanman
Time:: 09:18
Hi jakob, "borderTop" is the right way to refer to that property document.getElementById("test").style.borderTop = "2px solid green"; /Anpanman
Time:: 14:04
Anpanman, you're right. Quite simple!
rcastagna
Time:: 14:11
Jakob, As Anpanman points out, dropping the hyphen in border-top will give you the desired results. This is carried over for all of the hyphenated styles: background-color = backgroundColor font-weight = fontWeight margin-top = marginTop etc. I've also found that case is important to some of the browsers with strict interpretation, so make sure the second "word" in the attribute is capitalized. Something to look at that really helps with javascript (as well as other things HTML) is the Visibone charts found at http://www.visibone.com. I've got the "Card Collection" book, and there isn't a day that I don't look at it to find something I'm trying to resolve. I hope this helps, too...
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 an Answer Summary for the Summary 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
Time:: 14:06
Skip the hyphen and capitalize the next letter; i.e.: element.style.borderTop = "2px solid green"
Click here to see the Answer Discussion that preceded this summary.
Login to rate this summary: Good | Bad
Questions
Thanks for your reply. Where are you located? Whic...
i need to change the color of select (arrow and th...
how to include html file in my html page
How to repair Internet Explorer 7 in WIndows Vista...
Is there a way to track the open rate for marketin...
hi. i'm looking for the easiest way to create an e...
You have 100 characters to use
Rank
Expert
Points
1.
520
2.
510
3.
495
4.
475
5.
250
6.
150
7.
100
8.
75
9.
60
10.
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