Okay, so I want to make an HTML page with JavaScript. I want whatever I put in an input bar, to be translated differently. So for example if I put a in the box I want it to put ☺. And if I type a word like hello I want it to show as ◘♣♀♀☼. Would anyone know how to do that?
1 Answer
Here is an example in jQuery: http://jsfiddle.net/FPsdy/3/
You will have to fill the replacements array with what you want characters you want to.
var replacements = {
"A": ")",
"B": ">",
"C": "'",
}
$('input[value=Translate]').click(function(){
$("#translator").val(function(i, val)
{
val = val.split('');
$.each(val, function(i,e){
val[i] = replacements[e] ? replacements[e] : e;
});
return val.join('');
});
});
Source: jQuery replace with array