I just want to do the next cell data will be selected when I move from one cell to another cell by pressing Tab. Suppose I move from Firstname cell to Lastname cell, Then Lastname cell data will be selected automatically. In the following I have given my code and my need's image.Please help me to solve the problem.
$(document).ready(function() {
$("#btn").click(function() {
var ary = [];
$(function() {
$('#tbl tbody tr').each(function(a, b) {
var id = $('.id', b).text();
var fname = $('.fname', b).text();
var lname = $('.lname', b).text();
var email = $('.email', b).text();
ary.push({
ID: id,
fname: fname,
lname: lname,
email: email
});
});
alert(JSON.stringify(ary));
});
});
});
.tdstyle {
background: white;
color: #060606;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<div class="container">
<h2>Editable Table</h2>
<table id="tbl" class="table table-bordered table-responsive-md table-striped text-left">
<thead>
<tr>
<th>ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td class="id">101</td>
<td contenteditable class="tdstyle fname">John</td>
<td contenteditable class="tdstyle lname">Doe</td>
<td contenteditable class="tdstyle email">john@example.com</td>
</tr>
<tr>
<td class="id">102</td>
<td contenteditable class="tdstyle fname">Mary</td>
<td contenteditable class="tdstyle lname">Moe</td>
<td contenteditable class="tdstyle email">mary@example.com</td>
</tr>
<tr>
<td class="id">103</td>
<td contenteditable class="tdstyle fname">July</td>
<td contenteditable class="tdstyle lname">Dooley</td>
<td contenteditable class="tdstyle email">july@example.com</td>
</tr>
</tbody>
</table>
<input type="submit" class="btn btn-success btn-block" id="btn" value="Show Edit data">
</div>
My need is given in the following image.