2011-01-26 43 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" />'); 
    });