2

我的 html 中有一个 jquery 覆盖窗口以及一个激活按钮,这里是代码。

<!-- Validation Overlay Box -->
<div class="modal" id="yesno" style="top: 100px; left: 320px; position: relative; display: none; z-index: 0; margin-top: 100px;">
    <h2>  &nbsp;&nbsp;Authentication Failed</h2>

    <p style="font-family:Arial; font-size:small; text-align:center">
       Ether your username or password has been entered incorrectly.
       Please make sure that your username or password entered correctly...
    </p>

    <!-- yes/no buttons -->
    <p align="center">
        <button class="close"> OK </button>
    </p>
</div>

这是 Jquery 工具脚本

<SCRIPT>
$(document).ready(function() {
    var triggers = $(".modalInput").overlay({
        // some mask tweaks suitable for modal dialogs
        mask: {
            color: '#a2a2a2',
            loadSpeed: 200,
            opacity: 0.9
        },
        closeOnClick: false
    });

    var buttons = $("#yesno button").click(function(e) {
        // get user input
        var yes = buttons.index(this) === 0;

        // do something with the answer
        triggers.eq(0).html("You clicked " + (yes ? "yes" : "no"));
    });

    $("#prompt form").submit(function(e) {
        // close the overlay
        triggers.eq(1).overlay().close();

        // get user input
        var input = $("input", this).val();

        // do something with the answer
        triggers.eq(1).html(input);

        // do not submit the form
        return e.preventDefault();
    });

});
</SCRIPT>

在这里单击按钮或超链接如何调用它

"<BUTTON class="modalInput" rel="#yesno">You clicked no</BUTTON>"

我想要的只是我不想在单击按钮或通过链接时显示叠加层。是否可以通过诸如“showOverlay()”之类的javascript函数调用它?

4

1 回答 1

2

您有 2 个选项,您可以使用一个选项,如下所示load

var triggers = $(".modalInput").overlay({
 mask: {
  color: '#a2a2a2',
  loadSpeed: 200,
  opacity: 0.9
 },
 closeOnClick: false,
 load: true
});

这使它立即打开,您可以在此处查看 API 演示。如果您所追求的只是在设置click的某个时间点显示覆盖,只需触发它绑定到的事件,就像这样:

$(".modalInput").click();

这会触发与实际单击按钮或链接相同的处理程序行为,打开覆盖。

于 2010-06-12T11:40:43.500 回答