I have a working example of this but I'm not sure why my implementation isn't working. Can somebody please help? I'm missing something and I need another set of eyes to find it for me. :)
JSFiddle demo <-- see code here.
I'm trying to reproduce the functionality used here. I seem to be a little confused about passing/accessing the event
variable around.
Thanks!! :-)
I have a working example of this but I'm not sure why my implementation isn't working. Can somebody please help? I'm missing something and I need another set of eyes to find it for me. :)
JSFiddle demo <-- see code here.
I'm trying to reproduce the functionality used here. I seem to be a little confused about passing/accessing the event
variable around.
Thanks!! :-)
Share Improve this question asked Nov 12, 2012 at 15:41 JaxidianJaxidian 13.5k9 gold badges87 silver badges131 bronze badges 1- changing onChange to onClick works for me.. strange – Atif Commented Nov 12, 2012 at 15:45
3 Answers
Reset to default 5Bind to the Click event: example
$(document).ready(function() {
$('#checkbox1').click(function(event) {
if (flag) {
CancelEvent(event);
return event.returnValue;
}
SomeOtherStuff('this method has real functionality too');
});
});
Change is a little to late in the event structure to cancel the action that already happened. In addition, the return value was being omitted. So I added it to the event handler.
Working jsfiddle.
return false on checkbox click.
$('#checkbox1').click(function(event) {
return false;
});
you can either use disabled attribute of input
<input type="checkbox" id="checkbox1" disabled=disabled />
You forgot to add return event.returnValue;
and onClick will work instead of onChange?
http://jsfiddle/wanUF/11/