Make sure element is attached before trying to get value.