First of all, this is an invalid operation because you cannot add a div before or after li ,
the li element must be in the ul or ol container, and its siblings must be li .
try changing the structure: maybe put a div inside li
<ul> <li class="level1"><div></div></li> <li></li> <li></li> </ul> $('.level1').prepend('<div> Your content here</div>');
source share