0

I made a simple javascript translator using google API. Instead of using a button to translate the text i made onKeyUp="doTheFunction()" so that it translates once you type. At the bottom I have a button which clears the textareas. Once you clear the textareas and start typing again I get nothing. It seems that something like reset is missing ?

Here is a working fiddle: http://jsfiddle.net/5eC49/

Try to type Hello, press the button and type hello again?

Thanks alot

1 Answer 1

2

I would suggest setting .value rather than innerHTML when setting the translation result. Clear is setting value to '', but when the translation comes back, you're setting innerHTML instead of value. Apparently that is confusing the browser.

Works for me here: http://jsfiddle.net/jfriend00/WZmSa/

Sign up to request clarification or add additional context in comments.

1 Comment

I agree. This is likely killing the binding of the onkeyup event to the event handler. Alternatively, @rallyboy can rebind the event every time the "Clear" button is pressed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.