getAttributeOnSelection function