Can jquery add image to input?

I want to display the image in the input part (in the input field after the value word) Can jquery do this? Thank.

$("#click").click(function(){   
$("#text").append("<img class='loading' src='load.gif'/>");
...
});

<form name="form">
<input type="text" id="text">
<a id="click">search</a>
</form>
+3
source share
2 answers

You are trying to achieve this.

$("#click").click(function(){   
$("#text").css('background', 'url(load.gif);');
...
});

<form name="form">
<input type="text" id="text">
<a id="click">search</a>
</form>

I am wrong?

+3
source

You cannot insert image elements inside elements input type="text". However, you can:

  • Set the background image for the item
  • Overlay the image on top of it (without adding it inside it) using CSS
+3
source

All Articles