I have a form with a select element and an input field. I want to set the focus to the input field when the value of the select element changes. I tried using jQuery's focus() method, but it doesn't seem to work. Here's my code:
function moveToNextField(selectElement) {
console.log("got a call");
$(".myField").focus("focus");
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<script src="http://localhost/ibsv2/public/admin/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<td width="80">
<select name="tariff_code" class="form-control p-0 select2" onchange="moveToNextField(this)" id="tariff_code">
<option value="1" >One</option>
<option value="2" >Two</option>
<option value="3" >Three</option>
</select>
</td>
<td>
<input type="text" placeholder="Number" name="app_number" class="form-control p-0 myField" minlength="7" maxlength="7" id="app_number" required>
</td>