I am trying to move an li to the bottom of a ul, but can't figure out how to do it. I've looked at Move the first four list items to the end of the list and Move items in Ul Li up and down (this one didn't work because it was JQuery and I'm trying to use JS) , but neither worked. I've even tried to remove the li and add it back afterward, but couldn't get onclick to work.
Here is the ul:
<ul class="role_box_roles" id="rbroles">
<li class="role_box_role" style="border-color: rgb(255, 0, 0);">
<button class="role_remove_button" type="button" style="background-color: rgb(255, 0, 0);">-</button>
<span>Staff</span>
</li>
<li id="plusbutton"><button class="role_add" type="button" onclick="show_options()">+</button></li>
</ul>
The li that I need to keep at the bottom is the one with the "plusbutton" id. (I say keep in place because whenever I add a new item to the ul, it gets added below the "plusbutton" li)
The add_option function:
function add_option(optionname) {
var listItem = document.createElement("li");
var removeButton = document.createElement("button");
var optionSpan = document.createElement("span");
listItem.className = "role_box_role";
listItem.style = "border-color: rgb(255, 0, 0);";
//removeButton.type = "button";
removeButton.innerText = "-";
removeButton.className = "role_remove_button";
removeButton.style = "background-color: rgb(255, 0, 0);";
optionSpan.innerText = optionname;
listUl = document.getElementById("rbroles");
listUl.appendChild(listItem);
listItem.appendChild(removeButton);
listItem.appendChild(optionSpan);
}