Hi all

How can I write a javascript code to change the alignment of a textarea so that the user can select a part of of a textarea and change the alignment of this part by clicking a button?

10 Years
Discussion Span
Last Post by Fungus1487

Try the textAlign style.

But it may not work. The text alignment of a text box or a text area depends on the data type it is used for.


text-align Attribute | textAlign Property

Sets or retrieves whether the text in the object is left-aligned, right-aligned, centered, or justified

The property is read/write for all objects except the following, for which it is read-only: currentStyle . The property has a default value of left . The Cascading Style Sheets (CSS) attribute is inherited.

Applies To: BLOCKQUOTE , BODY , CENTER , currentStyle , DD , DIR , DIV , DL , DT , FIELDSET , FORM , hn , HR , INPUT type=password , INPUT type=text , LI , LISTING , MARQUEE , MENU , OL , P , PLAINTEXT , PRE , runtimeStyle , style , TABLE , TD , TEXTAREA , TH , TR , UL , XMP


but you still wont be able to align PART of the text differently to another part. Not in the same textbox anyway.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.