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="position:absolute;left:20;top:20;height:100;width:100;border-style:inset;border-color:#FF0000" onClick="Test()"></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
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="position:absolute;left:20;top:20;height:100;width:100;border-style:inset;border-color:#FF0000" onClick="Test()"></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