I’m having two jquery’s that I run and I want to combine them both in the same line.
Here’s an example of what i’m trying to do.
$(function(){
$('input').each(function(){
if ($(this).is(':checked')) {
$(this).after('this is checked');
}
});
$('input').click(function(){
if ($(this).is(':checked')) {
$(this).after('this is checked');
}
});
});
Now, both functions do the same thing, one is executed for checking if there are any inputs being checked from the backend, the other one just responds to user clicks.
I was thinking if i can combine them in a statement like this,
$('input').bind('each click');
but i noticed that even this wouldn’t work with each.
Any ideas?
Thanks!
Just name the function..
then use it in both situations: