C
christopher.secord
In the code below, I have an ordered list and a javascript function to
add new list items to the list. My problem is that the function adds
items to the bottom of the list. How can I go about adding items to
the top of (or anywhere else in the list)?
thanks
chris
<script type="text/javascript">
function addLI(id){
var Parent = document.getElementById(id);
var NewLI = document.createElement("LI");
NewLI.innerHTML = "this is a test";
Parent.appendChild(NewLI);
}
</script>
</head>
<body>
<input type="button" onclick="return addLI('test');" value="add LI">
<ol id="test">
<li>1</li>
<li>2</li>
</ol>
add new list items to the list. My problem is that the function adds
items to the bottom of the list. How can I go about adding items to
the top of (or anywhere else in the list)?
thanks
chris
<script type="text/javascript">
function addLI(id){
var Parent = document.getElementById(id);
var NewLI = document.createElement("LI");
NewLI.innerHTML = "this is a test";
Parent.appendChild(NewLI);
}
</script>
</head>
<body>
<input type="button" onclick="return addLI('test');" value="add LI">
<ol id="test">
<li>1</li>
<li>2</li>
</ol>