5

i wanted to show an image, only when the person starts typing into the text field.

i.e.

$('#type').keyup(function(){
//show the images
    });

html

<input type="text" name="type" id="type">

<div id="showimage"></div>

image

showimage.jpg
getaway
  • 8,792
  • 22
  • 64
  • 94

1 Answers1

12

jquery:

$('#type').keyup(function(){
   $('#image').show();
});

html:

<img id="image" src="showimage.jpg" style="display: none"/>
icyrock.com
  • 27,952
  • 4
  • 66
  • 85
  • In case I want to dismiss the image if I delete all the text in the form, how to do that? Thank you very much. – Lucky Luke Dec 31 '15 at 07:19
  • @LuckyLuke You can use [hide](http://api.jquery.com/hide/) for hiding. See also [this SOq](http://stackoverflow.com/questions/27518891/i-want-to-hide-fields-if-its-value-is-empty-and-image-src-also-in-html-using-jav) for similar examples. – icyrock.com Jan 02 '16 at 02:57