[英]set img as value for input type='text'?
<input type='text' id='txt'> <input type='button' id='btn' onclick='upv()' value='01'> <script> function upv() { document.getElementById("txt").value +="<IMG SRC='pics/smile/01.png'>"; } </script>
I am trying to make a function with js, it means that if a user clicks on an image , make input `value+= 'img'', I tried it with different ways and can't do it! 我正在尝试使用js创建函数,这意味着如果用户单击图像,然后输入`value + ='img',我将以不同的方式尝试它并且无法做到!
can any one suggest a solution? 有人可以提出解决方案吗?
You Can Get Image Name By using following Function 您可以使用以下功能获取图像名称
function getName() {
var fullPath = document.getElementById("img1").src;
var filename = fullPath.replace(/^.*[\\\/]/, '');
// or, try this,
// var filename = fullPath.split("/").pop();
document.getElementById("result").value = filename;}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.