Now there are several objects on the page that have a class .foo. When clicking on any of these objects, the #bar block changes its position.
$(function() { $('.foo').click(function(){ var foo_top = $(this).position().top; var foo_left = $(this).position().left; $('#bar').offset({top: foo_top + 10, left: foo_left + 10}); }); });
Because the code grows, I want to make the task of styles a separate function. What is the best way to do this?