Finding DOM node index

前端 未结 7 1910
死守一世寂寞
死守一世寂寞 2020-11-27 16:09

I want find the index of a given DOM node. It\'s like the inverse of doing

document.getElementById(\'id_of_element\').childNodes[K]

I want

相关标签:
7条回答
  • 2020-11-27 17:06

    using a framework like prototype you could use this :

    $(el).up().childElements().indexOf($(el))
    
    0 讨论(0)
提交回复
热议问题