Using Javascript to change the text alignment of a DIV tag

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tom@loopy.co.uk

    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.sty le.top="100px"; '
    but when I try to change the text alignment with the following:

    'window.xxx.sty le.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

    #2
    Re: Using Javascript to change the text alignment of a DIV tag

    <tom@loopy.co.u k> wrote[color=blue]
    >
    > It's no problem doing things like this: 'window.xxx.sty le.top="100px"; '
    > but when I try to change the text alignment with the following:
    >
    > 'window.xxx.sty le.text-align="left";'
    >
    > ... I get a syntax error probably due to the hyphen.[/color]

    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.styl e.textAlign="le ft";
    window.xxx.styl e.fontSize="110 %";
    etc.

    --
    hth
    ivo




    Comment

    • tom@loopy.co.uk

      #3
      Re: Using Javascript to change the text alignment of a DIV tag

      Brilliant ... thanks for your help

      Comment

      Working...