Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML&;CSS-更改输入按钮中的文本值_Html_Css - Fatal编程技术网

HTML&;CSS-更改输入按钮中的文本值

HTML&;CSS-更改输入按钮中的文本值,html,css,Html,Css,我正在尝试更改file类型的输入按钮的文本值。我知道它是参数值='',但在本例中它不起作用 我的代码: 您正在使用输入类型文件,因此无法更改该值 <input class="button-camera" type="file" accept="image/*" capture="camera" value="Take a photo" /> 改变类型 <input class="button-camera" type="Button" accept="image

我正在尝试更改file类型的输入按钮的文本值。我知道它是参数值='',但在本例中它不起作用

我的代码:






您正在使用输入类型
文件
,因此无法更改该值

<input class="button-camera" type="file" accept="image/*" capture="camera" value="Take a photo" />

改变类型

<input class="button-camera" type="Button" accept="image/*" capture="camera" value="Take a photo" />


页面标题
函数HandleBrowseClick()
{
var fileinput=document.getElementById(“浏览”);
fileinput.click();
}
函数Handlechange()
{
var fileinput=document.getElementById(“浏览”);
var textinput=document.getElementById(“文件名”);
textinput.value=fileinput.value;
}
没有选择任何文件

试试这个技巧,并在其中应用你的css类。

你说“不好用”是什么意思?查看这篇文章。这可能会有所帮助。您的意思是在用户输入文本之前,输入字段中出现的内容吗??OP打算使用输入类型文件。更改类型没有帮助请澄清您的答案首先尝试您的解决方案,然后告诉完整和清晰的答案以获得投票。这太完美了!谢谢你总是受欢迎的,伙计。
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
function HandleBrowseClick()
 {
var fileinput = document.getElementById("browse");
fileinput.click();
 }
function Handlechange()
 {
 var fileinput = document.getElementById("browse");
  var textinput = document.getElementById("filename");
  textinput.value = fileinput.value;
  }
</script>

 <input type="file" id="browse" name="fileupload" style="display: none"    onChange="Handlechange();"/>

 <input type="button" value="Take a photo" id="fakeBrowse"    onclick="HandleBrowseClick();"/>No file chosen
</body>
</html>