Dynamics of entanglement in one-dimensional spin systems