I have structure like this.
<ul class="gallerylist">
<li>
<image ...>
<input ...>
</li>
<li>
<image ...>
<input ...>
</li>
<li>
<image ...>
<input ...>
</li>
<p style="clear:both;"> </p>
</ul>
because of visual correction i have to use <p style="clear:both;"> </p> part and i’am adding new list items dynamically via JQuery by:
$('ul.gallerylist').append('<li><img .../><br/><input .../></li>');
but as you can guess it is appended after the <p style="clear:both;"> </p> part and it corrupts the visual correction.
My question is : Which way is true to add li inside ul as last but before p tag?
Note
I think your HTML markup is not valid, can’t place
pwithinullike you’ve done. Better would be wrap thepwithin anotherliand useCSSto accomplish you job.For example:
HTML
CSS
jQuery
DEMO
Read about .before(), it will insert an element before the matched element by selector.
OR
DEMO
Read about jQuery .insertBefore()
But, valid markup is necessary otherwise IE will make you mad. Comments below can give you some clues.