WEB前端

js input type=file文件选择上传框美化思路

位置:首页 > WEB前端 > js教程,2019-08-08 10:22
js input type=file文件选择上传框美化思路,具体美化效果只用css样式就行。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js input type=file文件选择上传框美化思路</title>
<style type="text/css">
#thefile
{
  -moz-opacity:0;
  filter:alpha(opacity=0);
  opacity:0;
  position:absolute;
  left:166px;
}
#thetext
{
  color:green;
  border:1px solid green;
  width:300px;
}
#bt
{
  border:1px solid green;
  width:80px;
}
</style>
<script type="text/javascript">
window.onload=function()
{
  var thefile=document.getElementById('thefile');
  var thetext=document.getElementById('thetext');
  function getValue()
  { 
    thetext.value=thefile.value; 
  } 
  thefile.onchange=function(){getValue();}
}
</script> 
</head>
<body> 
<input type=file id="thefile"/> 
<input id="thetext"/> 
<input type="button" value="选择文件" id="bt"/> 
</body> 
</html>

TAGS:input type=file美化

猜你喜欢

NewHot