Skip to content

Instantly share code, notes, and snippets.

@diegoponciano
Created July 5, 2010 17:50
Show Gist options
  • Save diegoponciano/464543 to your computer and use it in GitHub Desktop.
Save diegoponciano/464543 to your computer and use it in GitHub Desktop.
http://jsbin.com/ojija/3
http://bit.ly/inverte
String.prototype.reverse=function(){return this.split("").reverse().join("");}
function reverse(s){
return s.split("").reverse().join("");
}
$(document).ready(function () {
$("#inverteTexto").click(function(){
//var textoInvertido = reverse($("#texto").val());
var textoInvertido = $("#texto").val().reverse();
$("#textoInvertido").html(textoInvertido);
});
});
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
</style>
</head>
<body>
<p id="hello">Inversor de texto</p>
<input id="texto" type="text" />
<input id="inverteTexto" type="button" value="Inverter" />
<h3>Texto invertido</h3>
<p id="textoInvertido"></p>
</body>
</html>​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment