Search code examples
javascriptjqueryevent-handlinghtmlonload-event

Event handling on a textbox to load image


After onclick event has happened over a textbox,How can i load a particular image on the webpage? in JavaScript or jquery commands also would do!

Edit

<script> function try(ob){ 
 ob.<!-- i dont know what to do here --> } 
</script> . . . . 
<td><input type="text" class="inp-form" name="caseid" id="caseid" onclick="try(this)"/>       </td>

Solution

  • You can use following javascript & html as sample code to view an image on click of 'textbox'-

    JavaScript-

     $(document).ready(function(e) {
      $("#textbox").click(function(){
        $("#image").show('slow');           
      })    
    });
    

    html-

    <input type="text" name="test" id="textbox" /><br />
    <img src="images.jpg" id="image" style="display:none;" />
    

    It loads 'images.jpg' on click if '#textbox'. Hope it will help you.