$(".box").each(function(){
$(this).distance_left = function() {
return $(this).offset().left - $(this).parent().offset().left;
}
$(this).distance_top = function() {
return $(this).offset().top - $(this).parent().offset().top;
}
});
When I call distance_left or distance_top on a .box object, I simply get a box.distance_left is not a function. Why?