javascript - 用户上传后隐藏上传图片按钮

标签 javascript html css

上传图片后,我想隐藏上传图片按钮....

但是目前还没有隐藏.....

enter image description here

https://codepen.io/kidsdial/pen/RvLexz

<div class="container">

<label for="fileupa" class="customa">
    Upload Image
  </label>
  <input id="fileupa"  type="file" style="display:none;">


  <label for="fileupb" class="customb">
     Upload Image
  </label>
  <input id="fileupb"  type="file" style="display:none;">

<div class="minaimg masked-imga"    >
  <div  >
    <div class="minaimga">

      <img id="target_imga"  alt="">

      <div></div>

    </div>
  </div>
</div>

<div class="minaimg masked-imgb"    >
  <div >
    <div class="minaimgb">

      <img id="target_imgb"  alt="">

      <div></div>

    </div>
  </div>
</div>

</div>

<style>
.container {
    border: 1px solid #DDDDDD;
    width: 612px;
    height: 612px;
    position:relative;
    background:red;
}

.customa {
  border: 1px solid #ccc;
  display: inline-block;
  padding: 6px 12px;
  cursor: pointer; 
  position: relative;
    top: 350px;
    z-index: 1;
    left: 80px;
}

.customb {
  border: 1px solid #ccc;
  display: inline-block;
  padding: 6px 12px;
  cursor: pointer; 
  position: relative;
    top: 350px;
    z-index: 1;
    left: 180px;
}

.masked-imga

{

  -webkit-mask-image: url(http://139.59.24.243/ecom1/site/test/images/heart1.png);
  mask-image: url(http://139.59.24.243/ecom1/site/test/images/heart1.png);
  -webkit-mask-position: center center;
  mask-position: center center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;  

  width: 259px;
  height: 278px;
  position: absolute;
    top: 221px;
    left: 23px;

}



.masked-imgb 
{

  -webkit-mask-image: url(http://139.59.24.243/ecom1/site/test/images/heart2.png);
  mask-image: url(http://139.59.24.243/ecom1/site/test/images/heart2.png);
  -webkit-mask-position: center center;
  mask-position: center center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;  

    width: 416px;
    height: 388px;

    position: absolute;
    top: 111px;
    left: 173px;

}

.minaimga
{
  display: block;
  background-color: white;
  height: 278px;
}

.minaimgb 
{
  display: block;
  background-color: white;
  height: 388px;
}
</style>

<script>
fileupa.onchange = e => {
 target_imga.src = URL.createObjectURL(fileupa.files[0]);   
}

fileupb.onchange = e => {
 target_imgb.src = URL.createObjectURL(fileupb.files[0]);   
}
</script>

如果您需要有关此问题的任何其他信息,请告诉我....

我只需要隐藏上传图片按钮....

请帮我找到解决方案......

提前致谢....

最佳答案

这是更新后的 fiddle :

fileupa.onchange = e => {
  target_imga.src = URL.createObjectURL(fileupa.files[0]);
  document.getElementById('fileupa1').style.display = 'none';
}

fileupb.onchange = e => {
  target_imgb.src = URL.createObjectURL(fileupb.files[0]);
  document.getElementById('fileupa2').style.display = 'none';
}
   .container {
  border: 1px solid #DDDDDD;
  width: 612px;
  height: 612px;
  position: relative;
  background: red;
}

.customa {
  border: 1px solid #ccc;
  display: inline-block;
  padding: 6px 12px;
  cursor: pointer;
  position: relative;
  top: 350px;
  z-index: 1;
  left: 80px;
}

.customb {
  border: 1px solid #ccc;
  display: inline-block;
  padding: 6px 12px;
  cursor: pointer;
  position: relative;
  top: 350px;
  z-index: 1;
}

.masked-imga {
  -webkit-mask-image: url(http://139.59.24.243/ecom1/site/test/images/heart1.png);
  mask-image: url(http://139.59.24.243/ecom1/site/test/images/heart1.png);
  -webkit-mask-position: center center;
  mask-position: center center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  width: 259px;
  height: 278px;
  position: absolute;
  top: 221px;
  left: 23px;
}

.masked-imgb {
  -webkit-mask-image: url(http://139.59.24.243/ecom1/site/test/images/heart2.png);
  mask-image: url(http://139.59.24.243/ecom1/site/test/images/heart2.png);
  -webkit-mask-position: center center;
  mask-position: center center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  width: 416px;
  height: 388px;
  position: absolute;
  top: 111px;
  left: 173px;
}

.minaimga {
  display: block;
  background-color: white;
  height: 278px;
}

.minaimgb {
  display: block;
  background-color: white;
  height: 388px;
}
.button-div{
display: flex;
}
.button-div div{
align-items: center;
width: 50%;
}
<div class="container">

  <div class="button-div">
<div>
    <label for="fileupa" id="fileupa1" class="customa">
        Upload Image
    </label>
    <input id="fileupa" type="file" style="display:none;">
</div>
<div>     
    <label for="fileupb" id="fileupa2" class="customb">
        Upload Image
    </label>
    <input id="fileupb" type="file" style="display:none;">
</div> 
</div> 

  <div class="minaimg masked-imga">
    <div>
      <div class="minaimga">

        <img id="target_imga" alt="">

        <div></div>

      </div>
    </div>
  </div>

  <div class="minaimg masked-imgb">
    <div>
      <div class="minaimgb">

        <img id="target_imgb" alt="">

        <div></div>

      </div>
    </div>
  </div>

</div>

关于javascript - 用户上传后隐藏上传图片按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54551939/

相关文章:

javascript - 如何通过按文本来集成警报? (在React Native中)

javascript - query 选择未被点击的div增加其宽度

javascript - 从下拉表单中选择加载页面

html - 如何在 CSS 中设置最小字体大小

python - 如何在 HTML/CSS 中整齐地格式化代码?如果可以的话,我特别想使用 Python Docutils 的数字圆标注

javascript - jQuery DataTables fnRender 增量列

javascript - 难以对齐文本元素

Javascript变量不能正确添加两个变量,只能连接

css - 使用下拉菜单进行顶级导航 : have IE bugs pt. 2

html - Firefox 中不同的填充输入和按钮