<div id="modalBox">
<dialog>
<button id="close">Χ</button> <!-- x ->
<form method="post" action="result.html"><!--(表示向何处发送表单数据) -->
<p> 名字:<input name="name" type="text" > </p>
<p> 密码:<input name="pass" type="password" > </p>
<p>
<input type="submit" name="Button" value="提交"/>
<input type="reset" name="Reset" value="重填" />
</p>
<textarea name="showText" cols="x" rows="y">文本内容 </textarea>
</form>
</dialog>
</div>
<button id="show">显示对话框</button>
<script>
var modalBox = document.getElementById("modalBox")
var dialog = document.querySelector("dialog");
document.querySelector("#show").onclick = function(){
showModal()
};
function showModal(){
modalBox.style.display='block';
}
document.querySelector("#close").onclick = function(){
close();
};
function close(){
modalBox.style.display="none";
}
</script>
html+js 弹出对话框(模态框)
最新推荐文章于 2022-04-14 16:20:13 发布