Reputation: 21
How can I reverse text in HTML? If I write "apple" I want to change it to "elppa". Here is what I have tried. But it only changes the text direction!
Upvotes: 0
Views: 4705
Reputation: 1
you can do it like this
if you want to use for every input attribute in your page.
.input {
text-align:right;
unicode-bidi:bidi-override;
direction:rtl;
}
OR
If you want to affect one input.
First name: <input type="text" style="text-align:right;unicode-bidi:bidi-override; direction:rtl;"/>
Upvotes: 0
Reputation: 1501
You can use javascript
for it like this
function reverseString(str) {
return str.split("").reverse().join("");
}
var rstring = reverseString("apple");
console.log(rstring)
or you can do it in html like this
<p>
‮ apple
</p>
Upvotes: 3
Reputation: 10404
Taken from css tricks
.rtl {
unicode-bidi:bidi-override;
direction:rtl;
}
<div>apple</div>
<div class="rtl">apple</div>
Upvotes: -1