Monday, August 20, 2012

jquery – Return a variable from a Javascript function

How can I access the value of imgWidth? This is giving me undefined.



somejQueryMethod(function() {
var imgWidth;
$(\"<img/>\").attr(
\"src\",
$(\"#SomeImgSelector\").attr(\"src\")
).load(function() {
imgWidth = this.width;
});
// use imgWidth here
});






Rating: 1 out of 5 based on 3 ratings



The post jquery – Return a variable from a Javascript function appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/jquery-return-a-variable-from-a-javascript-function.html

No comments:

Post a Comment