Trying to fill a series of input fields so that always the first empty input is filled. Code seems to always fill the first input...any ideas?
jQuery(document).ready(function() {
for (i = 0; i < 4; i++) {
$('.field:empty:first').val(i);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class="field" /><br/>
<input class="field" /><br/>
<input class="field" /><br/>
<input class="field" /><br/>
<input class="field" /><br/>