Javascript examples for String Operation:String Reverse
Reverse a string in html
<html> <head> <title>7.23</title> <meta charset="utf-8"> <script> String.prototype.reverse=function(){ return this.split("").reverse().join(""); }/*www . j a v a 2 s. co m*/ </script> </head> <body> <p> <label for="s">Input</label> <input type="text" id="s" size="25"> </p> <p id="t"></p> <input type="button" id="r" value="Reverse" onclick="document.getElementById('t').innerHTML = document.getElementById('s').value.reverse();"> </body> </html>