开发者

Change background image of a div from <input> without page refresh

I have <input type="file"> tag. I need to select an image and change the background of the开发者_如何学运维 image to the input image without refreshing or reloading the page. Is it possible ? If yes, how to do it ?


It is possible, but you'd have to make an AJAX file uploader - Javascript can't access the contents of a file input any any meaningful way.


You can use jQuery and do this:

$('#imgID').attr ('src', 'new path');

That will change the image without reloading the page.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜