Home  >  Article  >  Web Front-end  >  返回对象在当前级别中是第几个元素的实现代码_javascript技巧

返回对象在当前级别中是第几个元素的实现代码_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:11:361295browse
复制代码 代码如下:

//语法:prev(element)
//参数:element对象
//返回:对象在当前级别中是第几个元素,从1开始
//2010-08-26 15:13:55
function prev(elem,cont) {
if(!cont){cont=1}
elem = elem.previousSibling;
if(elem){return prev(elem,(cont+1))}
return cont
}

prev($("ext-gen232"))
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn