0

Hi guys....
I am having trouble changing the color of the LEFT border in a table.

i'm using the following javascript:

document.getElementById("cell1").style.border-left="3px red solid";

cell1 is the correct id of the table cell.
If i take away the "-left" part in "border-left", it will change the border of the whole cell. Problem is, i need to change only SPECIFIC borders.

Any Suggestions?

Rock On

3
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by FC Jamison
1

Try "borderLeft" instead. One of the unfortunate aspects of web development is that the CSS property may or may not have a corresponding JavaScript property, and they don't always map directly to each other. Also, as you can see, the spelling will differ.

So, "style.borderLeft" is the JavaScript property that changes the "border-left" CSS declaration.

Here's a nice cross-reference: http://codepunk.hardwar.org.uk/css2js.htm

Votes + Comments
Huge help! provided great reference as well
0

Javascript doesn't use the hyphens that are present in CSS.

As a general rule, if the CSS style is border-left, margin-top, etc, the javascript equivalent will be borderLeft, marginTop, etc.

What do the call that...camel code? Something like that.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.