I have a textarea with direction from right to left
#myTextarea
{
direction: rtl;
}
on an event, with jquery, i change the direction from left to right :
$('#myTextarea').css('direction', 'ltr');
this move the whole content of the textarea from right to left.
I want to move only the current line, and let the previous lines in their default direction.
Is there a way to achieve that ?
Add dir="rtl" to the html tag any time the overall document direction is right-to-left (RTL). This sets the default base direction for the whole document. All block elements in the document will inherit this setting unless the direction is explicitly overridden.
For example, the en-US locale (for US English) specifies left-to-right. Most Western languages, as well as many others around the world, are written LTR. The opposite of LTR, RTL (Right To Left) is used in other common languages, including Arabic ( ar ) and Hebrew ( he ).
The direction CSS property sets the direction of text, table columns, and horizontal overflow. Use rtl for languages written from right to left (like Hebrew or Arabic), and ltr for those written from left to right (like English and most other languages).
This is not possible, the text direction can only apply to the entire textarea
element, not the lines within it.
You can try inserting '\u202E'
characters at the beginning of the line, which will change the direction.
Also note that this is more of a hack than a real solution, it might not work in all browsers and on all platforms, I would try to think hard about if this is really what I want. Maybe you would be better off with a rich text editor.
Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With