尝试自动增加表单的步骤号。表单的某些元素可能会隐藏或显示,具体取决于上面的答案。
HTML
<div class="confirmation-step">
<span class="step-number"></span>
</div>
<div class="confirmation-step" style="display:none;">
<span class="step-number"></span>
</div>
<div class="confirmation-step">
<span class="step-number"></span>
</div>
jQuery
$('.confirmation-step').each(function() {
if($(this).is(':visible')) {
//set variable stepNum
//Haven't come up with anything good yet
} else {}
$(this).find('.step-number').html(stepNum);
});
示例输出
<div class="confirmation-step">
<span class="step-number">1</span>
</div>
<div class="confirmation-step" style="display:none;">
<span class="step-number"></span>
</div>
<div class="confirmation-step">
<span class="step-number">2</span>
</div>
谢谢!
最佳答案
关于javascript - 如果元素可见,则自动增加步数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24317024/