How to get it? These p's are all sibling elements. How to get the sequence number of one of these p's?
<p</p>//序号0
<p</p>//序号1
<p</p>//序号2
<p</p>//序号3
<p</p>//序号4
滿天的星座2017-05-19 10:11:19
function index(el) {
return Array.prototype.indexOf.call(el.parentElement.children, el)
}
某草草2017-05-19 10:11:19
Read in a loop through the prevSiblings of the element, and read a count+1 until no more is read. The final count is the index
大家讲道理2017-05-19 10:11:19
Determine how many nodes there are in front of a certain p, and add one for each additional serial number, until there is no node in front, and then the serial number value of the current node is obtained