I am struggling to create a dynamic spinner within a table's tbody using Bootstrap 4. Here is what I have attempted so far:
HTML
<div class="container mt-2">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div>
<span class="table-title">table</span>
</div>
<hr>
<div class="table-responsive text-nowrap">
<table id="contact-list" class="table table-striped table-bordered table-sm bstable">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Click</th>
</tr>
</thead>
<tbody>
<td>a</td>
<td>b</td>
<td>c</td>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
CSS
.bstable tbody {
position: relative;
}
.bstable tbody .overlay-spinner {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 10;
}
JS
var s = '<div class="spinner-grow text-primary spinner-grow-sm mt-2"><span class="sr-only">Loading...</span></div>;
$( '.bstable' ).find( 'tbody' ).append( '<div class="overlay-spinner text-center">' + s + '</div>' );
When testing on Firefox, the spinner displays correctly within the tbody, but on Chrome, Edge, and Explorer, it appears above the table.
Here is my JSFiddle
I'm struggling to pinpoint the issue. Can you assist me in resolving this problem?
Thank you