すべての入力が満たされているかどうかを確認した後にdivを表示する方法を理解しようとしていますが、#intro-info
セクション内の入力をチェックしたいだけです。私は、すべての入力が記入されている場合は、ボタン#intro-button
ディスプレイを作るためにelse文で書くことが何かわからない。すべての入力が記入されている場合にdivを表示
$(function() {
var intro = $('.intro');
intro.on('keypress', function() {
if ($(this).val().length > 1) {
$(this).next('.intro').addClass('block');
}
/* else {
$('.intro').hide();
}*/
});
var allEmpty = true;
$('#intro-info :input').each(function() {
if ($(this).val() !== '') {
allEmpty = false;
return false; // we've found a non-empty one, so stop iterating
} else
});
return allEmpty;
});
.intro {
opacity: 0;
padding: 10px 15px;
margin: 20px auto;
}
.intro:first-child {
display: block;
opacity: 1;
}
.block {
display: block;
opacity: 1;
-webkit-animation: fadein 1s ease-in;
-moz-animation: fadein 1s ease-in;
animation: fadein 1s ease-in;
}
.next {
display: none;
}
#intro-button {
\t display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="intro-info">
<input id="name" type="text" class="intro">
<input id="email" type="email" class="intro">
<input id="title" type="text" class="intro">
<button id="intro-button">Proceed</button>
</div>
<a class="next">show div</a>
あなたは各ボックスは、上のボックスが満たされている場合にのみ表示するように、私は感じています。私は儀式ですか? – Iceman
@Iceman "_入力のすべてが入力された場合、ボタンをイントロボタンで表示させる_" – Andreas
@アンドレアス私は同意します。しかし、コードのこの部分を見てください: '$(this).next( '。intro')。addClass( 'block');' mayb私はちょうど混乱しました。 – Iceman