I'm trying to call a function in two different event handlers. The function runs, but doesn't seem to recognize the passed variable ( or maybe the variable isn't getting passed). It just triggers the alert "nothing".
I'm not understanding how to use console.log() or where exactly to look and see what's going on?
Right now, I put it in the function, like I'm showign below. When I test the page in firefox, I go to Firebug, and click on console. I clear everything, then trigger the event, and I'm not sure what I'm looking at... or if I'm even looking in the right place. Or if I even put console.log() in the right place?
Here's what I have
function pic_shift(){
$("#testit").removeClass("main_page");
if ( $(this).hasClass('active') ) {
/* do stuff */
} else if ( $(this).hasClass('one') || $(this).hasClass('ee')) {
/* do other stuff */
} else {
alert('nothing');
console.log($(this));
};
}
$('.square-container,.main-nav,.reg3,.privacy_policy,.subnav').on('click', '.square','.main', function(event) {
pic_shift( $(this));
});
:
When I look at console, I see in "all" this: Object[Window #]
When I look at errors, I see nothing.
I should add that when the function isn't separated out and called, it works perfectly fine, and knows what 'this' is.