jquery check detection, hiding previous
HTML
<input type="text" class="date" value="Date" /><input type="checkbox" class="check" /><span class="hide">Hide</span><br>
<input type="text" class="date" value="Date" /><input type="checkbox" class="check" /><span class="hide">Hide</span><br>
<input type="text" class="date" value="Date" /><input type="checkbox" class="check" checked="checked" /><span class="hide">Hide</span><br>
CSS
body {
font-family: sans-serif;
}
input[type=text] {
padding: 10px;
color: #aaa;
margin: 0 10px 10px 0;
border: 1px solid #ddd;
font-family: sans-serif;
}
input[type=checkbox] {
margin-right: 3px
}
.hide {
font-size: 10px;
text-transform: uppercase;
color: #aaa;
}
JavaScript
$(document).ready(function() {
$('.check').each(function() {
$(this).prev().toggle(!$(this).is(':checked'));
});
$('.check').click(function() {
$(this).prev().toggle();
});
});