This is some different different method to do the same thinkthing:
$(document).ready(function (){
$('#isAgeSelected').click(function() {
// $("#txtAge").toggle(this.checked);
// usingUsing a pure CSS selector
if ($(this.checked)) {
alert('on check 1');
};
// usingUsing jQuery's is() method
if ($(this).is(':checked')) {
alert('on checked 2');
};
// // usingUsing jQuery's filter() method
if ($(this).filter(':checked')) {
alert('on checked 3');
};
};
});
});
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<input type="checkbox" id="isAgeSelected"/>
<div id="txtAge" style="display:none">Age is something</div>