0

I have a question more out of curiosity. I have written the following code

function checkBox() {
if($(this).prev().is('.click-animation')) {
   TweenMax.to(this, 0.5, {
       background: 'red'
   });
} else {
    TweenMax.to(this, 0.5, {
        background: 'green'
    });
}    

}

$('.click-animation').on('click', function() {
    checkBox();
});

And this way it will not activate. Possibly because it cannot define $(this) and I'd like to know why.

Now the function works if I just past it inside the click event it's only when I take it to an outside function that it does nothing.

So why does it not recognize $(this) and what can I do to use it if I were to use an outside function.

Thank you very much

0 Answers0