javascript - Get Imagesize in jQuery -


i want imagesize in jquery, have code. works point of

alert (v); 

i wonder wrong rest when v contains value.

 var v = $('#xxx input').val();     alert (v);     var newimg = new image();     newimg.src = v;     var height = newimg.height;     var width = newimg.width;     alert ('the image size '+width+'*'+height); 

thanks jean

your code image size won't work. image loads asynchronously, height , width not available immediately. you'll need following:

var newimg = new image(); var height, width;  newimg.onload = function() {     height = newimg.height;     width = newimg.width;     window.alert('the image size '+width+'*'+height); };  newimg.src = v; 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -