我的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> 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>"所有我想要的是,我不想在点击按钮或通过链接显示覆盖。是否可以通过javascript函数调用它,比如"showOverlay()“??
发布于 2010-06-12 19:40:44
你有两个选择,有一个你可以使用的load option,如下所示:
var triggers = $(".modalInput").overlay({
mask: {
color: '#a2a2a2',
loadSpeed: 200,
opacity: 0.9
},
closeOnClick: false,
load: true
});这会让它立刻打开,you can see the API demo here。如果您想要在设置后的某个时间显示覆盖,只需触发它绑定的事件click,如下所示:
$(".modalInput").click();这将触发与实际单击按钮或链接相同的处理程序行为,即打开覆盖。
https://stackoverflow.com/questions/3028279
复制相似问题