Document Ready & Change Combined
I want to show/hide areas based on the state of a checkbox and the value of a radio group, this works but looks long-winded & can someone tell me a more elegant way to do this please so its fired on page load and checkbox state change:
- $(document).ready(function() {
if ( ($('#val_0').not(':checked').length) && ($("input[name='val_1']:checked").val() == 'custom') ) {
$(".custom-row").show()
}else{
$(".custom-row").hide();
});
$(function () {
$('#val_0').change(function () {
if ( ($('#val_0').not(':checked').length) && ($("input[name='val_1']:checked").val() == 'custom') ) {
$(".custom-row").show();
}else{
$('.custom-row').hide();
}
});
});