开发者

can jquery append an image in input part?

I want to peend an image in input part.(in the input box, after the v开发者_Go百科alue word) Can jquery do that? Thanks.

$("#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>


You're 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>

am I wrong?


You cannot insert image elements inside of input type="text" elements. You can however:

  • Set the image as a background on the element
  • Overlay the image on top of it (not appending it inside it) using CSS
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜