I would like to get this toggle
bootstrap effect on a table i.e. get that scroll up effect but all I get is it fading in and out with some horrible effect.
I leave you a bit of code:
$(function () {
$('.btn_show').click(function (ev) {
$('#contenido').slideToggle("slow");
});
})
.input-sm{
height: 20px;
font-size: 9pt;
width: 100%;
}
.letra{
font-size: 9pt;
}
table {
border-collapse: collapse;
border-left: 1px solid #000;
border-right: 1px solid #000;
width: 100%;
}
tr {
border-bottom: 1px solid #000;
}
input:[type=text]{
border-bottom: 1px solid #C00;
border: 0;
outline: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<table width="100%">
<thead style="background:#000;text-align:center;">
<tr>
<td colspan="4">
<a class="btn_show" href="#!" style="color:#fff; font-size:12px"><strong>C.- Antecedentes</strong></a>
</td>
</tr>
</thead>
<tbody id="contenido" style="display:none">
<tr>
<th>
Peso RN:
</th>
<td>
<input type="text" class="input-sm">
</td>
<th>Parto:</th>
<td>
<input type="text" class="input-sm">
</td>
</tr>
<tr>
<td colspan="2">
Obs. Perinatales
</td>
<td colspan="2">
<input type="text" class="input-sm">
</td>
</tr>
<tr>
<td colspan="2">
Obs. Perinatales
</td>
<td colspan="2">
<input type="text" class="input-sm">
</td>
</tr>
</tbody>
</table>
How to get that scroll effect in an html table?
You must add two more options to your
CSS
, apply adisplay:block
to the elementtbody
, when performing this process, it will be necessary to modify the width of the rowstr
andtbody
(otherwise it would be misaligned) , this is achieved withdisplay:table;width:100%;
Also use the
ev.preventDefault();
when performing theclick
on a link and it will not perform the redirection. ;)eg
Change the
display: none
from<tbody>
todisplay: block
that way what you are looking for is fulfilledI misspelled the previous answer, this should work