Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Using Javascript to change the text alignment of a DIV tag (http://www.velocityreviews.com/forums/t922515-using-javascript-to-change-the-text-alignment-of-a-div-tag.html)

tom@loopy.co.uk 01-20-2006 06:15 PM

Using Javascript to change the text alignment of a DIV tag
 
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


Ivo 01-20-2006 06:43 PM

Re: Using Javascript to change the text alignment of a DIV tag
 
<tom@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




tom@loopy.co.uk 01-23-2006 10:58 AM

Re: Using Javascript to change the text alignment of a DIV tag
 
Brilliant ... thanks for your help



All times are GMT. The time now is 07:44 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57