The use of $(this) in jQuery
<p>When writing code using jQuery i find myself using var self = $(this) to reference the current context of the object i'm in. For example:</p>

<pre><code>$('#myDiv').click(function(e){

var self = $(this);

self.css('background', 'red');

});
</code></pre>

<p>This is great but I have to repeat this process for every object. Example:</p>

<pre><code>$('#myDiv').hover(function(){

//hover over function
var self = $(this);
self.css('background', 'red');

}, function(){

//hover out function
var self = $(this);
self.css('background', 'blue');

});
</code></pre>

<p>My question is is there any way i can set a global variable of self and use it to reference the context i'm in. So i want to gloably set self = $(this) and no matter where i use it it will automatically reference the current object i'm in? </p>
