I'm using dhtmlgoodies drag-drop-folder-tree and when you click save you get the
id-parentid, id-parentid, etc...
i want to have the li index within it's ul so i can tell their order as well - so i want it to look like this:
id-parentid-orderid, id-parentid-orderid, ETC...
their code is not jquery (i know how to do it in jquery with the index()
but it is pure JS
how do i get the index of an element within his parent?
You'll have to write your own index function ;)
eg lets say that liNode is an <li>
node within an <ul>
function index(array, element) {
for (var i = 0; i < array.length; i++) {
if (array[i] == element) return i;
i++;
}
return -1;
}
var allLiNodes = liNode.parentNode.childNodes;
var myIndex = index(allLiNodes, liNode);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.