Use the unicodeBidi property in JavaScript to set whether the text should be overridden to support multiple languages in the same document. Set it to normal, embed or bdi-override. The bdi-override allows you to add the direction too i.e. rtl to ltr.
Example
You can try to run the following code to learn how to work with unicodeBidi property in JavaScript
<!DOCTYPE html> <html> <body> <p id = "pid" style="direction:rtl">Demo Text</p> <button type="button" onclick="display()">Set</button> <script> function display() { document.getElementById("pid").style.unicodeBidi = "bidi-override"; } </script> </body> </html>