js 自带的三种弹框
生活随笔
收集整理的這篇文章主要介紹了
js 自带的三种弹框
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1?警告框alert()
2?確認框confirm()
3?提示框prompt()
一個代碼
<!DOCTYPE html>
<html><head><meta charset="utf-8" /></head><body><p id="demo"></p><button onclick="click1()">彈出警告框</button><button onclick="click2()">彈出確認框</button><button onclick="click3()">彈出提示框</button><script>function click1() {alert("大家好才是真的好")}function click2() {if(confirm("溫馨提示!")) {console.log("點擊確認")} else {console.log("點擊取消")}}function click3() {var txt;var person = prompt("請輸入您的名字:", "");if(person == null || person == "") {txt = "用戶取消輸入";} else {txt = "你好," + person + "!今天過得好嗎?";}document.getElementById("demo").innerHTML = txt;}</script></body></html>
?
總結
以上是生活随笔為你收集整理的js 自带的三种弹框的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: getElementById 使用
- 下一篇: 心急吃不了热豆腐的下一句是什么呢?