📜  获取索引 vanilla js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:53.784000             🧑  作者: Mango

代码示例1
function index(el) {
  if (!el) return -1;
  var i = 0;
  do {
    i++;
  } while (el = el.previousElementSibling);
  return i;
}