Reputation: 804
I placed a listener on all checkboxes on my page with .on('change')
. When clicking on a checkbox it actually detects the change and fires a function. BUT, when I use a jQuery function to set a checkbox to checked like so: $('#checkboxOne').prop('checked', true)
the .on('change')
doesn't detect a change? How come?
Upvotes: 0
Views: 100
Reputation: 1697
If you want to fire jquery function it self, then you should write your function in $(document).ready(function(){ });
Upvotes: 0
Reputation: 1329
Kartikeya Khosla is right
The 'change' event is only fired when a user triggers it. Setting properties from within your own code will not trigger events.
Upvotes: 1