Hoisting?


#1


Hi, I'm just wondering why javascript hoisting does not apply in the following example? I placed the variable declaration below the function and received an error message stating that $target is undefined.

Isn't the declaration supposed to be 'hoisted' to the top?


$(document).ready(function() {
    $target.fadeOut('fast');
    var $target = $("#jq")
});


#2

you first specify you want to fadeOut $target, then you specify what $target is. That doesn't work.

i can't fadeOut a target if i don't know what the target is, and neither can the computer


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.