How can I update a variable outside of a function? For example I have this:
var max_index = 0;
//loop through the z-index's
$(".widget_container").each(function(){
if($(this).attr("z-index") > max_index){
max_index = $(this).attr("z-index") + 1;
}
});
alert(max_index);
The only problem with this is that max_index is always alerting 0. How can I have that update the max_index?