I'm working on a project where I have a checkbox and I want a function to run when the checkbox changes form ticked to unticked or vice versa.
Here is the checkbox:
<input class="form-control main_checkbox_class"
type="checkbox"
value="1"
checked="checked"
id="main_checkbox_id" >
And then in my javascript I have:
jQuery(function($) {
$('.main_checkbox_class').change(console.log('hello'));
});
However when I run this, on page load 'hello' is printed to the console and then nothing happens when I check or uncheck the check box, I'm not sure why this is happening and any help fixing this would be greatly appreciated.