Looking at your code, your passing in a jQuery object, rodd
, into a function to return a jQuery object $(rodd).click...
It might be easier to do
$('#checkBox').click(Callme);
function Callme(rodd){
if(this.checked){
// do some behavior
}
}
or
$('#checkBox').click(Callme);
function Callme(rodd){
if($(this).is(':checked')){
// do some behavior
}
}
this also does away with the anonymous function event handler that is only executing Callme()
passing in the event target. Working Demo here.
EDIT:
Currently, Callme(rodd)
above expects a HTMLElement object
to be passed in. If you want to be able to pass in a jQuery object, simply change to this
$('#checkBox').click(function(event) {
Callme($(event.target));
});
function Callme(rodd){
if(rodd.is(':checked')){
alert('checked');
}
}
although personally, I would keep it as an element to be passed in and do the wrapping in the Callme
function. you might want to consider prefixing the rodd
parameter with $
to make it obvious that a jQuery object is expected.