Attach event listeners only to target elements.