I'm very new to namespace and global variables. I presently have this code:
$('#formats1').hover(function() {
var tag = 'div.cds';
var offset = $(this).position();
var width = $(tag).outerWidth();
var height = $(tag).outerHeight();
$(tag).show();
$(tag).css('left', offset.left - width + 'px');
$(tag).css('top', offset.top - height + 'px');
}, function() {
$("div.cds").hide();
});
$('#formats2').hover(function() {
var tag = 'div.lp';
var offset = $(this).position();
var width = $(tag).outerWidth();
var height = $(tag).outerHeight();
$(tag).show();
$(tag).css('left', offset.left - width + 'px');
$(tag).css('top', offset.top - height + 'px');
}, function() {
$("div.lp").hide();
});
This is repeated many times for various divs at the moment.
I feel like this would be a good opportunity to incorporate a namespace & global variables but I'm unsure how to do it. Any ideas?
Thanks!