Change left-border of a table cell with javascript

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jul 2006
Posts: 11
Reputation: AndrewSmith is an unknown quantity at this point 
Solved Threads: 0
AndrewSmith AndrewSmith is offline Offline
Newbie Poster

Change left-border of a table cell with javascript

 
0
  #1
Aug 30th, 2006
Hi guys....
I am having trouble changing the color of the LEFT border in a table.

i'm using the following javascript:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. 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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Change left-border of a table cell with javascript

 
1
  #2
Aug 30th, 2006
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
Last edited by tgreer; Aug 30th, 2006 at 4:19 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 434
Reputation: FC Jamison is on a distinguished road 
Solved Threads: 20
Team Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: Change left-border of a table cell with javascript

 
0
  #3
Sep 1st, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Change left-border of a table cell with javascript

 
0
  #4
Sep 1st, 2006
camelCase
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 434
Reputation: FC Jamison is on a distinguished road 
Solved Threads: 20
Team Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: Change left-border of a table cell with javascript

 
0
  #5
Sep 1st, 2006
That's it!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC