Insert Element Between Other Elements

Avatar of Chris Coyier
Chris Coyier on

For example, if you have five paragraphs in a row and you need to insert a break tag in between all of them. You can’t put it before all five (you don’t need one at the top) or after all five (you don’t need one at the bottom), you only need four.

$("p:not(:last-of-type)").after("<br />");