Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'-' character in style-properties

Status
Not open for further replies.

wanmaster

Programmer
Nov 20, 2000
94
NL
I make a games in JavaScript and use lot of style-changes.
Does anyone know how to avoid the problem with a '-' character in JavaScript?
For example:

I have a something like this in the body-section:

<DIV id=divTest style=&quot;position:absolute;left:20;top:20;height:100;width:100;border-style:inset;border-color:#FF0000&quot; onClick=&quot;Test()&quot;></DIV>

And this in the head-section:

<script language=JavaScript>

function Test() {

divTest.style.background='#0000FF'; //works fine
divTest.style.border-color='#0000FF'; //won't work
}
</script>

I have tried anything: eval() functions, charcodes etc. but I still haven't found a way to avoid the error caused by '-'.

Is there any way to do this, or should I just give up?

Remedy
 
commonly, when there is a dash in a css property, you use the following transofrmation:

border-style becomes:

borderStyle

So remove dashes, and make the first letter of the second word capital jared@eae.net -
 
Thanks, you saved me from complete insanity && frustration...

Remedy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top