i have $("#text") and i want to make it so that when you type the word 'replace me' into $("text"), it is automatically replaced with the phrase 'replaced successfully' and 'goodbye' with 'hello'
i'm assuming the right way to go about doing this would be to find 'replace' with regex and replace it and this is about as far as i've gotten
$('#text').keydown(function(){ var text = $('#text').text(); var replaceCommand = ['replace me', 'goodbye']; var replaceOutput = ['replaced successfully', 'hello']; for (var i=0; i < replaceCommand.length; i++){ text.replace(replaceCommand[i]/i, replaceOutput[i]); } });