【发布时间】:2018-07-12 05:09:57
【问题描述】:
我尝试在弹出框上添加下一个按钮。现在它以特定顺序运行弹出窗口。此外,当最终弹出窗口打开时,按钮会自动禁用。但有一个问题。当我删除一些模式时,代码不起作用。我想按该顺序运行弹出窗口,当我删除一些弹出窗口时,弹出窗口希望正确运行。另外,我想创建上一个按钮。我该怎么做?请帮我解决问题。
这是我使用的代码。
$(document).ready(function() {
var currentmodal = 1;
$(".getAssignment").click(function() {
var $divs = $(".modalDialog");
var modal = $("*[data-modalorder="+(currentmodal++)+"]");
if(!$("*[data-modalorder="+currentmodal+"]").length)
{
modal.find("input.getAssignment").prop("disabled",true);
}
if ($divs.length > 0 && modal) {
window.location.href = "#" + $(modal).attr("id");
}
});
});
<input class="getAssignment" type="button" value="Open Modal">
<div id="openModal" class="modalDialog" data-modalorder=1>
<div>
<input class="getAssignment" type="button" value="Previous">
<input class="getAssignment" type="button" value="Next">
<a href="#close" title="Close" class="close">X</a>
<h2>Modal Box 1</h2>
<p>This is a sample modal box that can be created using the powers of CSS3.</p>
<p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
</div>
</div>
<div id="openModal2" class="modalDialog" data-modalorder=2>
<div>
<input class="getAssignment" type="button" value="Previous">
<input class="getAssignment" type="button" value="Next">
<a href="#close" title="Close" class="close">X</a>
<h2>Modal Box 2</h2>
<p>This is a sample modal box that can be created using the powers of CSS3.</p>
<p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
</div>
</div>
【问题讨论】:
标签: javascript html css arrays