Declaring Jquery variables at beginning of script
I would like to declare several variables at the beginning of my script.
As I understand it a global variable can only be created outside of a
function anyways. Below is a snippet of code I am using. when the
declaration of $map is at position 2 only then the code executes as
expected but when at position 1 it does not work. Apart from the downside
of being unable to group my declarations I would like to know what is the
cause of this difference and what consequences it has
var transMatrix = [1, 0, 0, 1, 0, 0];
var homeMatrix = [1, 0, 0, 1, 0, 0];
var $map = $('svg > g'); //1
$(document).ready(function () {
var $map = $('svg > g'); //2
zoomSVG($map, 2);
});
No comments:
Post a Comment