DirectionToggle

JS to switch direction between Right-to-Left and Left-to-Right
Toggle the direction of a textarea from RTL to LTR to RTL
This is a quick JS code to do that, was used in one of my Dawnfoods projects

CodeFunctionName
What is this?

Public

Tested

Original Work
< button type="button" class="btn btn-default btn-lg" style="margin-top:10px;" onclick="DirectionToggle('textarea')" >
< i class="fa fa-caret-left" > < /i > < i class="fa fa-paragraph" > < /i > < i class="fa fa-caret-right" > < /i > < /button >



< script >
function DirectionToggle(cntrl) {
    var dii = document.getElementById(cntrl).style.direction;
    if (dii== "rtl")
        document.getElementById(cntrl).style.direction = "ltr"
    else
        document.getElementById(cntrl).style.direction = "rtl"
    ;
    /* or we can use jquery, like this */
    /* $("#IngBody2").css("direction", "rtl"); */
}
< / script >





Older version, just in case
< script >
function IngDirSwitch1() {
    var dii = document.getElementById("IngBody1").style.direction;
    if (dii== "rtl")
        document.getElementById("IngBody1").style.direction = "ltr"
    else
        document.getElementById("IngBody1").style.direction = "rtl"
    ;
    /* or we can use jquery, like this */
    /* $("#IngBody2").css("direction", "rtl"); */
}
function IngDirSwitch2() {
    var dii = document.getElementById("IngBody2").style.direction;
    if (dii== "rtl")
        document.getElementById("IngBody2").style.direction = "ltr"
    else
        document.getElementById("IngBody2").style.direction = "rtl"
    ;
}
< / script >



cntrl

included in code

Views 1,746

Downloads 577

CodeID
DB ID