连接两个字符串并在剪贴板中获取值

时间:2019-05-17 06:19:49

标签: javascript

如何连接两个字符串并在剪贴板中获取值?

var url = "www.myurl.123";
var img = document.getElementById("myInput2").value;
var optionValue = url + " " + img;

  optionValue.select();
  document.execCommand("copy");
  alert("Img path: " + optionValue.value);

1 个答案:

答案 0 :(得分:1)

您可以将其添加到输入值

var url = "www.myurl.123";
var img = document.getElementById("myInput2")
img.value = url + " " + img.value


img.select();
document.execCommand("copy");
alert("Img path: " + img.value);
<input id="myInput2" value="image"/>