views:

18

answers:

2

i have following code,i stored value in imgwidth variable

var newImg = new Image();
        newImg.src = document.getElementById('image').src;
        var height = newImg.height;
        var width = newImg.width;
            var width_img = width/3;
            jQuery.mynamespace = {imgwidth : width_img};

how can i retrieve imgwidth variable globally?

A: 

something like this?:

function testa() {
   jQuery.test = {data: 1, data2: 2};
}

testa()

alert(jQuery.test.data  + "\n" + jQuery.test.data2);
​

example

andres descalzo
+1  A: 

You can say jQuery.mynamespace.imgwidth, because jQuery is available globally.

Sorpigal