construct click functionality around an element