Problem:
I want to insert content as the last child of an element. To reproduce what i want, i created this fiddle: http://jsfiddle.net/lexhartman/zx0r8mnu/2/
The jquery-code i am using, is the following:
jQuery(document).ready(function() {
var $collectionHolder = $('div.collectionholder');
var $innerDivOne = $('<li><p>TEST 1 also has to be green</p></li>');
var $innerDivTwo = $('<li><p>TEST 2 also has to be green</p></li>');
var $outerDivChunk = $('<div class=parentdiv><div class="subdiv"><ul class="ul-list"></ul></div></div>').append($innerDivOne).append($innerDivTwo);
$collectionHolder.append($outerDivChunk);
});
But... the lis are being appending to the div, not the ul inside the div.
Goal:
What i want to achieve is that the two innerdiv's (li's with no classname) are inserted in the "ul" div (with classname: ul-list).
Attempts:
The outerdiv variable has to stay the same (i know that when the outerdiv only has the "ul" it works, but in my code that will bring a lot of other headaches which i won't be bothering you with.. :D).
I am guessing i will be needing an other function then append, but which one or maybe i can use append in another way then i am doing now?
Thanks!