Currently I have this radio buttons
- Eletronics
- Computers
- Others
What I am trying to do is, if radio button Others
is selected, I would like to display an input text field and let the user type.
What I would like to do is, when I select Others
and type something inside the input field, then when I choose back to Eletronics
or Computers
, I would like to clear the text that I wrote inside input field.
Please kindly provide me with the solution of JavaScript or jQuery.
Here is my code sample. Please kindly check it: http://jsfiddle.net/dnGKM/
You add the
jQuery
tag to your question, so that should do the trick using jQuery :)CSS:
HTML:
JS:
You can use this:
to clear the input field.
===============HTML
===============jQuery
Please add below code of line in your code:
now its look like:
This would be helpful for you.
UPDATE
DEMO