【问题标题】:How to upload an image using image url from web in javascript or jquery?如何在 javascript 或 jquery 中使用来自网络的图像 url 上传图像?
【发布时间】:2015-08-22 22:14:45
【问题描述】:

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

【问题讨论】:

  • 问题出在哪里?花了几个小时后让您失败的代码在哪里?
  • enchine marre.. surukke mool points ijind yaan sayyond ulle.. eer kuda down vote malthondullar..
  • 使用任何 jquery 插件来做到这一点。你可以在这里找到它...bestfreewebresources.com/…

标签: javascript jquery angularjs upload


【解决方案1】:

您需要有一个文本框,您可以在其中输入图像的 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"/>

【讨论】:

    【解决方案2】:
    • 它只是更新图像的“src”属性并显示图像。并且没有保存,并且它的性能不像输入类型 ='file'。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-17
      • 2014-03-19
      • 2011-04-27
      • 2011-10-15
      • 1970-01-01
      • 1970-01-01
      • 2018-07-14
      • 1970-01-01
      相关资源
      最近更新 更多