2011-01-26 63 views
0

我想从用户点击输入字段(不预载图像)时从服务器拉出图像。焦点jQuery请求图像

我发现下面的代码显示了当输入处于焦点时跨度中的文本,但是如何更改以请求图像?

<!DOCTYPE html> 
<html> 
<head> 
<style>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> 

感谢

回答

0

删除跨度,并添加DIV代替,然后就更新你的方法

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