懸浮框

1.寫了一個簡單的懸浮框以下javascript

test(){
    //寫入
    let suspensionBox= document.createElement("div");
    suspensionBox.setAttribute("style","background-color:rgba(0,0,0,0.3);position:absolute;margin-top: 44px;width:100vw;height:30px;border:solid 1px #696969;");

    var oneButton = document.createElement("input");
    oneButton.setAttribute("type","button");
    oneButton.setAttribute("value","x");
    oneButton.setAttribute("style","background-color: #A9A9A9;float: right;");
    suspensionBox.appendChild(oneButton);

    var text = document.createElement("input");
    text.setAttribute("type","button");
    text.setAttribute("value","我是懸浮框**老人 在客廳");
    text.setAttribute("style","color:white");
    suspensionBox.appendChild(text);

    document.body.appendChild(suspensionBox);
    //刪除
    let that = this;
    oneButton.onclick=function(){
      document.body.removeChild(suspensionBox);
    }
  }
相關文章
相關標籤/搜索