开发者

jQuery request image on focus

I would like to pull an image from the server when a user clicks into an input field (without preloading the image).

I have found the following code that shows text in a span when the input is in focus, but how would that need to be changed to request an image?

<!DOCTYPE html>
<html>
<head>
<st开发者_开发知识库yle>span {display:none;}</style>
<script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
</head>
<body>
<p><input type="text" /> <span>focus fire</span></p>
<script>
  $("input").focus(function () {
    $(this).next("span").css('display','inline').fadeOut(1000);
  });
</script>
</body>
</html>

Thanks


Remove span, and add div instead and then just update your method

  $("input").focus(function () {
    $(this).next("div").html('<img src="location to image" />');
  });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜