I am developing an application using which users can update their twitter status. Then it fetches all messages(i.e. updates) sent by its users & display them in diff windows sorted by msg type. The msg displaying code is:
echo' <ul id="msg" name="msg">';
foreach ($xml->entry as $status) {
echo'<li>'.$status->content.'</li>';
}
echo'</ul>';
What now I need to do is that any new messages could be entered as a sub-list items of another message that is already displayed there. Like if a messages ‘A’ is displayed by app, user could enter a new message ‘B’ as its sub-list item. I need to make three levels i.e. parent msg, subLevel-1, & subLevel-2
Try this:
1. give the parent element(the ‘ul’) an id or a name, for instance ‘<ul id=”dynamicList”>’.
2. create the element you would like to generate (in this case ‘li’):
var element1 = document.createElement(‘li’);
element1.innerHTML = “foobar”;
3. After you’re done creating whatever elements you needed, append the elements where they belong:
document.getElementById(‘dynamicElement’).appendChild(element1);