Using Javascript to change the text alignment of a DIV tag

Discussion in 'Javascript' started by tom@loopy.co.uk, Jan 20, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Ivo Guest

    <> 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
    Ivo, Jan 20, 2006
    #2
    1. Advertising

  3. Guest

    Brilliant ... thanks for your help
    , Jan 23, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    744
    John C. Bollinger
    Jan 27, 2006
  2. Mel

    DIV + Text alignment

    Mel, Apr 20, 2004, in forum: Javascript
    Replies:
    0
    Views:
    95
  3. M Wells
    Replies:
    0
    Views:
    128
    M Wells
    Oct 6, 2004
  4. mscir
    Replies:
    3
    Views:
    296
    Martin Honnen
    Jun 26, 2005
  5. visu
    Replies:
    4
    Views:
    277
Loading...

Share This Page