We study the dynamics of entanglement for a one-dimensional spin chain with a nearest neighbor time-dependent Heisenberg coupling J(t) between the spins in presence of a time-dependent external magnetic field h(t) at zero and finite temperatures. We consider different forms of time dependence for the coupling and magnetic field; exponential, hyperbolic and periodic. We examined the system size effect on the entanglement asymptotic value. It was found that for a small system size the entanglement starts to fluctuate within a short period of time after applying the time dependent coupling. The period of time increases as the system size increases and disappears completely as the size goes to infinity. We also found that when J(t) is periodic the entanglement shows a periodic behavior with the same period, which disappears upon applying periodic magnetic field with the same frequency. Solving the particular case where J(t) and h(t) are proportional exactly, we showed that the asymptotic value of entanglement depends only on the initial conditions regardless of the form of J(t) and h(t) applied at t > 0.