Reputation: 953
Hi I have included given code
<input type="text" name="test" placeholder="test1" tabindex="1">
<input type="text" name="test" placeholder="test2" tabindex="2">
<input type="text" name="test" placeholder="test3" tabindex="3">
<input type="text" name="test" placeholder="test4" tabindex="4">
<input type="text" name="test" placeholder="test5" id = 'mytest' tabindex="5">
<button tabindex="6" id="add" class="button">Add</button>
Now I want when I click on add button then automatically tabindex focus on
<input type="text" name="test" placeholder="test5" id = 'mytest' tabindex="5">
. Something to be written on this click function . Please guide me how to solve this.
$('#add').click(function(){
var tab = $('#mytest').attr('tabindex')
........
})
Upvotes: 0
Views: 1549
Reputation: 7117
$('#add').click(function(){
$('input[tabindex=5]').focus();
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" name="test" placeholder="test1" tabindex="1">
<input type="text" name="test" placeholder="test2" tabindex="2">
<input type="text" name="test" placeholder="test3" tabindex="3">
<input type="text" name="test" placeholder="test4" tabindex="4">
<input type="text" name="test" placeholder="test5" tabindex="5">
<button tabindex="6" id="add" class="button">Add</button>
Upvotes: 2