简体   繁体   English

JavaScript模式关闭问题

[英]Javascript modal close issues

So I have a modal that opens when a UI icon is clicked and for some reason the modal will not close in any browser other than IE. 所以我有一个模式,当单击UI图标时会打开,并且由于某种原因,该模式在IE以外的任何浏览器中都不会关闭。 Is there a simpler way of doing this? 有没有更简单的方法可以做到这一点? Or any browser specification I can add? 还是我可以添加的任何浏览器规范?

Here is my code: 这是我的代码:

<!-- 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>

Not sure why, but it will not let me indent or return on my code. 不知道为什么,但是它不会让我缩进或返回我的代码。 Apologize for the poor readability. 抱歉,可读性很差。

You can try the following (assuming you're using jquery): 您可以尝试以下操作(假设您正在使用jquery):

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

The above code will toggle the modal (show it if it's hidden, or hide it if it's already visible) when you click the "ui" button 当您点击“ ui”按钮时,以上代码将切换模式(如果已隐藏则显示它,或者如果已经可见则隐藏它)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM