125
rated 0 times
[
132]
[
7]
/ answers: 1 / hits: 20563
/ 10 Years ago, tue, december 23, 2014, 12:00:00
I want to hide a table row (with input fields inside) when a checkbox is checked.
I found something that works:
HTML
<table>
<tr id=row>
<td><input type=text></td>
<td><input type=text></td>
</tr>
<tr>
<td><input type=checkbox id=checkbox>Hide inputs</td>
</tr>
</table>
Script
$(document).ready(function () {
$('#checkbox').change(function () {
if (!this.checked)
$('#row').fadeIn('slow');
else
$('#row').fadeOut('slow');
});
});
But this only works if the checkbox is not checked already. So if the checkbox is checked at the beginning, I want the table row to be hidden. How do I do this?
Please note that I don't know much about JavaScript, but I really need this
More From » jquery