Programming Tips - jQuery: react to a value change

Date: 2021jan29 Library: jQuery Language: javaScript Q. jQuery: react to a value change A. If you have this html:
<input type=text id=mytext>
Use this code:
$(document).ready(function() { $('#mytext').change(function() { console.log('changed to ' + $(this).val()); }); });
Or for a checkbox:
<input type=checkbox id=mycheck>
Use this code:
$(document).ready(function() { $('#mycheck').checked(function() { const val = $(this).prop('checked'); console.log('changed to ' + val); }); });