0
我有12個模態。我想每一個模態的.modal__content
高度比作viewport height
,如果一個特定的模式.modal__content
高度<比vh
addClass("center")
它else
addClass("margin")
,然後進入下一個模式 - 比較一下,做if
聲明,以此類推,直到最後一個模態。迭代如果語句
每個模態具有相同的類.modal__content
。
這是我if
:
if ($(window).height() > $('.modal__content').actual('height')) {
$('.modal__content').addClass("center");
} else {
$('.modal__content').addClass("margin");
}
一個模式的例子:
<div class="modal" id="modal-3"> // each modal has it's own id
<div class="modal__content">
<h3>Heading</h3>
<div>
<p>Paragraph</p>
<button class="md-close">close</button>
</div>
</div>
</div>
問題:
1)式中的循環方式,我應該把我的if
? Mb我根本不需要循環?
2)$('.modal__content').addClass("center");
- 是隱迭代我怎麼能限制它只是一個特定的模式?
哇!謝謝!有效! – Edgar
快樂編碼!請接受答案(y) – Tushar