美文网首页
原生js学习-----Dialog Box

原生js学习-----Dialog Box

作者: 翻滚的前端程序员 | 来源:发表于2017-04-10 18:16 被阅读77次

    原生js学习

    1. alert()

    显示带有一条指定消息和一个 OK 按钮的警告框

    alert('hello alert');
    
    alert

    没有返回值

    var a = alert("hello");
    console.log(a)  //undefined
    

    2. confirm()

    显示一个带有指定消息和OK及取消按钮的对话框

    confirm("Are you Ready?")
    
    confirm

    有返回值

    var a = confirm("Are you Ready?")
    
    如果点击确定,则 a = true
    如果点击取消,则 a = false
    

    3. prompt()

    显示可提示用户进行输入的对话框

    prompt("what's your name?");
    
    prompt

    有返回值

    var txt = prompt("what's your name?");
    
    则 txt = “输入的内容”
    

    相关文章

      网友评论

          本文标题:原生js学习-----Dialog Box

          本文链接:https://www.haomeiwen.com/subject/tjceattx.html