471,873 Members | 949 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,873 software developers and data experts.

Using Javascript to change the text alignment of a DIV tag

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

Jan 20 '06 #1
2 13663
Ivo
<to*@loopy.co.uk> wrote

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.

--
hth
ivo
http://4umi.com/web/javascript/camelcase.htm

Jan 20 '06 #2
tom
Brilliant ... thanks for your help

Jan 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Stumped and Confused | last post: by
reply views Thread by blaircraig | last post: by
2 posts views Thread by Tor Inge Rislaa | last post: by
2 posts views Thread by Jerry | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.