Sure there’s something tiny wrong with my syntax… Here is stripped down version of my code…
function example1() {
var thumbWidth = $(this).find('img').width();
//some more code
};
function example2() {
$('div').each(function(){
example1();
thumbTotal = thumbWidth + xx //etc.;
});
};
$(document).ready(function(){
example2();
});
My problem is that example1 is not being executed in the code above. I’ve tried inserting the example1 code manually and this works fine. I want to be able to call example1 elsewhere so it’s important that it’s isolated within a separate function.
Many thanks.
Based on you edited post you’ve got at least two ways to solve the situation:
1st: Define a return value for example1()
2nd: Define an appropiate scope for the variable ‘thumbWidth’