$(document).ready(function () {
    $(".cursor-pointer").click(function () {
        $('#dialog').show();
    });
    $('#dialog').click(function (e) {
        var e = e || window.event; //浏览器兼容性
        var elem = e.target || e.srcElement;
        while (elem) { //循环判断至跟节点，防止点击的是div子元素
            if (elem.id && elem.id == 'dialog-content') {
                return;
            }
            elem = elem.parentNode;
        }
        $('#dialog').css('display', 'none'); //点击的不是div或其子元素
    });
    $('#copyBtn').click(function (e) {
        const range = document.createRange();
        range.selectNode(document.getElementById('copyBT'));
        const selection = window.getSelection();
        if (selection.rangeCount > 0) selection.removeAllRanges();
        selection.addRange(range);
        document.execCommand('copy');
        $('#copyBtn').html('复制成功，打开微信，粘贴搜索');
        $('#toast').show().delay(3000).fadeOut();
    });
});