Using Javascript to change the text alignment of a DIV tag

T

tom

Hi there,
In IE, I am trying to govern various style attributes of a DIV tag with
javascript.

It's no problem doing things like this: 'window.xxx.style.top="100px";'
but when I try to change the text alignment with the following:

'window.xxx.style.text-align="left";'

.... I get a syntax error probably due to the hyphen.

Does anyone have any ideas about this? Other style attributes can be
changed but not text alignment. I would be very grateful for some help.

Thanks ....

Tom
 
I

Ivo

It's no problem doing things like this: 'window.xxx.style.top="100px";'
but when I try to change the text alignment with the following:

'window.xxx.style.text-align="left";'

... I get a syntax error probably due to the hyphen.

That 's right. To avoid the hyphen, you write combinations of words in
camelcase, with the first letter of the next word capitalized:

window.xxx.style.textAlign="left";
window.xxx.style.fontSize="110%";
etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top