attach listeners to an element