|
Hi there...
I wrote a function that will inserts a list item somewhere in the middle of the list (technically, it's right before the list item that is marked with an id="something")
Here it is...
function addListItem(lcTag, lcText, lcClassName) {
var currentNode = document.getElementById(lcTag);
var list = currentNode.parentNode;
var newNode = document.createElement("li");
var spanNode = document.createElement("span");
var newTextNode = document.createTextNode(lcText);
spanNode.appendChild(newTextNode);
if (lcClassName)
{
spanNode.className=lcClassName;
}
newNode.appendChild(spanNode);
list.insertBefore(newNode, currentNode);
}
Here's how the function would be passed...
addUserListItem('before this item', 'For more information, check out our help page', 'black')
My problem is that I may want to break the lcText string into two lines. Is there a way to pass this through the argument?
Thanks
Donna
|