multiple jquery functions
I have 3 jquery functions. Do i need to put them under separate functions or i need to put them put into one function? see below:
1. put in multiple functions:
- <script>
- $(function() {
- $('#calc_jyform').calx();
- });
- $(function() {
- $("#checkboxID").change(function(){
- $("#tableID tr.rowClass").toggle(!this.checked);
- });
- });
- $(function() {
- $('#checkboxID').click(function() {
- var cb1 = $('#checkboxID').is(':checked');
- $('#emailAddr').prop('disabled', !cb1);
- });
- });
- </script>
2. put into 1 function:
- <script>
- $(function() {
- //jquery calx do calculation
- $('#calc_jyform').calx();
-
- //toggle table row upon checkbox click
- $("#checkboxID").change(function(){
- $("#tableID tr.rowClass").toggle(!this.checked);
- });
- //enable form field upon checkbox click
- $('#checkboxID').click(function() {
- var cb1 = $('#checkboxID').is(':checked');
- $('#emailAddr').prop('disabled', !cb1);
- });
- });
- </script>