Making a translator using jQuery
Making a translator using jQuery
I'am trying to make a translator but it doesn't work, when I write something in
the textarea which is in my array, it must write in the other textarea "Done" but it doesn't.
jQuery('document').ready(function ()
var $write = jQuery('textarea[name=edit]')
var $read = jQuery('textarea[name=unedit]')
var words = ["mouse", "head", "month"]
var $button = jQuery('button')
$button.click(function ()
for (var i = 0; i <= words.length; i++)
if ($write == words[i])
$read.text("Done")
else
setInterval(function ()
$read.text("Undone((")
, 1500)
)
)
I used val , it didn't work
– Tigran Avagyan
Aug 28 at 9:16
When someone asks a question about a problem with their code, we need to know what is wrong with it. Stating that “it doesn’t work” is not helpful.
– Liam
Aug 28 at 9:21
1 Answer
1
$write is an object that references your textarea. You need to use .val() to retrieve its text, like this:
$write
.val()
if ($write.val() == words[i]) {
Also the rest of your logic can be better, e.g. you now add multiple timers that keep writing "Undone((" which does not make much sense.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
its working for me , check if you getting $write or not,
– Ahmed Sunny
Aug 28 at 9:14