繁体   English   中英

如何使用javascript或jquery中的图片网址上传图片?

[英]How to upload an image using image url from web in javascript or jquery?

我有一个页面,我需要使用它的URL从网上添加图片,并使用Jquery或Javascript将其显示在我的页面中,与下面的图片相同。

在此处输入图片说明

您需要有一个文本框,您可以在其中输入图像的URL和一个附加事件的按钮。

 var button = document.getElementById("button"), input = document.getElementById("input"), image = document.getElementById("image"), src; // button click event button.onclick = function(){ // in case you want to use somewhere else src = input.value; // set the image src to the input value image.src = src; } 
 <input id="input" type="text"/> <button id="button">click me</button> <img id="image" height="200px"/> 

  • 它只是更新图像“ src”服饰并显示图像。 并且未保存,并且其性能不如输入类型='file'。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM