Pregunta

I need to add HTML Tags in a precise position using Javascript

<div id="myId">
   <div id="addAfter"><div>
   <***here I need to add a set off HTML Tags***>
   <div ><div>
   <div><div>
</div>

javascript code

  var ol = '<ol id ="div_blue"><li><img id="blueUp" src="<c:url    value="/resources/style/images/btup.png"/>" alt =""/></li><li>....</li>< /ol>' ;
  $("#myId").InsertInPosition2(ol);

but how to define InsertInPosition2?

thanks

imprim ecran

enter image description here

¿Fue útil?

Solución

Use .after()

$("#addAfter").after(ol);

Demo: Fiddle

If you want to add the element with reference to the parent element then

$("#myId").children().first().after(ol);

Demo: Fiddle

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top