Global variables that can be used in multiple jQuery functions
- by YouBook
Can you be able to contain variables that can be used in multiple functions in jQuery, example:
var self = $(this);
var box = self.parents('.box');
$('#title').click(function()
{
    self.css('background', 'red');
    box.slideDown('slow');
}).dblclick(function()
{
    self.css('background', 'green');
    box.slideUp('slow');
});
So that self and box can be used within these event functions so I don't have to keep doing this:
$('#title').click(function()
{
    var self = $(this);
    var box = self.parents('.box');
    self.css('background', 'red');
}).dblclick(function()
{
    var self = $(this);
    var box = self.parents('.box');
    self.css('background', 'green');
});
But question is, is it possible, if so, how can you do that?