Javascript模式关闭问题

时间:2013-11-08 20:08:44

标签: javascript html5 function modal-dialog

所以我有一个模式,当点击一个UI图标时打开,由于某种原因,模态不会在IE以外的任何浏览器中关闭。有更简单的方法吗?或者我可以添加的任何浏览器规范?

这是我的代码:

<!-- Click function for modal -->
$(ui).click(function modal() {
    el = document.getElementById("modal");
    el.style.visibility = (el.style.visibility == "visible")?"hidden":"visible";
});


<div id="modal" class="modal" draggable="true">
<div>
<h3 style="text-decoration: underline"> Summary Report Table </h3>
    <table id="summary">
        <tr>
            <th> Trans Count </th>
            <th> Trans Amt </th>
            <th> Match Count </th>
        </tr>
        <tr>
            <td> 300 </td>
            <td> $200,000 </td>
            <td> 4 </td>
        </tr>
    </table>
    <a href='#' onClick='modal()'>Close</a>
</div>

不确定原因,但它不会让我缩进或返回我的代码。为可读性差而道歉。

1 个答案:

答案 0 :(得分:0)

您可以尝试以下方法(假设您使用的是jquery):

$(ui).click(function () {
    $("#modal").toggle();
});

当你点击“ui”按钮时,上面的代码将切换模态(显示它隐藏,或隐藏它,如果它已经可见)