Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Using Javascript to change the text alignment of a DIV tag

Reply
Thread Tools

Using Javascript to change the text alignment of a DIV tag

 
 
tom@loopy.co.uk
Guest
Posts: n/a
 
      01-20-2006
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

 
Reply With Quote
 
 
 
 
Ivo
Guest
Posts: n/a
 
      01-20-2006
<(E-Mail Removed)> 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



 
Reply With Quote
 
 
 
 
tom@loopy.co.uk
Guest
Posts: n/a
 
      01-23-2006
Brilliant ... thanks for your help

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select text within a div tag by clicking on content of div tag or a button? visu Javascript 4 11-22-2006 06:25 AM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
NS/FF don't change div offsetWidth when div innerHTML is added toand div becomes wider mscir Javascript 3 06-26-2005 04:04 PM
How to get the text in html tag.like<div...><font...>Text</font></ =?Utf-8?B?Tmlja3k=?= ASP .Net 2 02-20-2005 03:03 PM
Select text within a div tag by clicking on content of div tag? M Wells Javascript 0 10-06-2004 11:04 AM



Advertisments