zoukankan      html  css  js  c++  java
  • js自定义弹窗

    <一>confirm弹窗

    页面操作中常见需要确认操作。

    例如:删除某条消息前需要确认是否删除。

    页面中弹窗确认操作用到confirm消息对话框。

    JS代码

    function del(){
      var del = confirm("确认要删除吗?");
      if(del == true){
          //执行删除操作
          alert("该条评论已删除!");
      }else{
          //未删除返回
          alert("未删除");
      }
    }
    JS部分example

    页面代码

    <!--调用确认删除函数-->
    <input name="button" type="button" onClick="del()" value="删除"/>
    HTML部分example

    ps:JS函数递归

    var count = 1;
      function click(){
        var str = confirm("是否再次执行该函数?");
        if(str == true)
        {
            alert("已执行第"+count+"次");
            count += 1;
            click();
        }
        else
        {
            alert("结束执行该函数");
        }
      }
    JS部分 example
    <input name="button" type="button" onClick="click()" value="点我" />

     <二>prompt弹窗

    接收输入值,并对该值做操作。

      function rec(){
        var score; 
        score = prompt("输入你的成绩");
        if(score>=90)
        {
           document.write("你很棒!");
        }
        else if(score>=75)
        {
           document.write("不错吆!");
        }
        else if(score>=60)
        {
           document.write("要加油!");
        }
        else
        {
           document.write("要努力了!");
        }
      }
    JS部分example
  • 相关阅读:
    [openjudge] 2797最短前缀 Trie
    [poj]1050 To the Max dp
    [openjudge] 1455:An Easy Problem 贪心
    [poj] Catch That Cow--bfs
    = =
    dinic算法实现
    Dinic
    走进链式前向星的秘密
    树链剖分前传
    树链剖分
  • 原文地址:https://www.cnblogs.com/MirageFox/p/5235859.html
Copyright © 2011-2022 走看看