Skip to main content
Home / Code Snippets / jQuery Code Snippets / Insert Element Between Other Elements

Insert Element Between Other Elements

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 />");
icon-link icon-logo-star icon-search icon-star