zoukankan      html  css  js  c++  java
  • HTML DOM confirm()方法使用

    confirm()方法用于显示一个带有特点消息的确定和取消的对话框,当用户点击确定时confirm()方法返回true,当用户点击取消时confirm()方法返回false.

    1. 触发事件时使用

    <html>
        <head>
            <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
            <script type="text/javascript" src="jquery-1.9.1.js"></script>
            <script type="text/javascript">
                $(function() {
                    
                    $("input[value").click(function() {
                        if(confirm("你确定触发事件?")) {
                            /*
                             *当点击对话框的确定按钮时,返回true时执行业务逻辑
                                 *如果直接将click()直接绑定在按钮,即:<input onclick="change();"/>
                             *方法需要返回值
                                */
                            alert("你已经确定触发事件了。。。");
                        }
                    });
                    
                    $("#con").click(function() {
                        if(confirm("你确定触发链接上的事件吗?")) {
                            $("#con").attr("href","http://www.baidu.com");
                        }
                    });
                    
                });
            </script>
        </head>
        <body>
            <input type="button" value="测试confirm()方法"/>
            <br/><br/>
            <a href="" id="con" target="_blank">连接上使用confirm()方法</a>
        </body>
    </html>

     

  • 相关阅读:
    学习shell script
    ubuntu11.10安装出现/cdrom问题以及不能格式成ext问题
    正则表达式
    认识与学习bash(2)
    UNIX网络编程 一个简单的时间获取客户程序
    HDU4522
    恢复引导
    认识与学习bash(1)
    文件格式化处理
    C++解析csv文件
  • 原文地址:https://www.cnblogs.com/shi-blog/p/4477699.html
Copyright © 2011-2022 走看看