<div id="saveCode" class="center" style="display:none;width:300px;height: 350px;">
<form>
    <input type="image" id="cancel" onclick="cancel()"
           src="cancelIcon.png" style="position: relative;top:8px;left: 267px;height: 25px;">
    <div style="position: relative;top:15px;left: 58px;font-size: medium;">
        二维码ID:20142132948
    </div>
    <div style="position: relative;top:50px;left: 76px;background: grey;height: 150px;width: 150px;">

    </div>
        <input type="button" onclick="save()" value="保   存"
               style="position: relative;top: 90px;left: 92px;width: 115px;height: 40px;
          border: none;  font-size: large;color: white;background: #358DE6;">
</form>
</div>

下面是js:

function add() {
    document.getElementById("saveCode").style.display="block";
}
应该是点击上一个按钮后可以出现当前div,但实际上出现了一下就消失了,网页刷新了。
问题是formform表单默认提交你所填的数据,而你并没有写跳转的网页(form中有个action属性),因为连接为空 他就会刷新一次 导致你每次都是空的
解决方案直接删除<form></form>

相关文章:

  • 2022-12-23
  • 2022-02-20
  • 2021-08-24
  • 2021-05-13
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
相关资源
相似解决方案