FF火狐下獲取一個元素同類型的相鄰元素實現(xiàn)代碼
更新時間:2012年12月15日 14:20:57 作者:
FF火狐下獲取一個元素同類型的相鄰元素實現(xiàn)代碼 ,需要的朋友可以了解下
復(fù)制代碼 代碼如下:
// 兼容火狐獲取一個節(jié)點的相同類型的上一個相鄰節(jié)點
function perviousSiblingSameType(node , cnode )
{
// 為空直接返回null
if(node.previousSibling == null )
{
return null ;
}
else
{
// 節(jié)點類型不相等繼續(xù)遞歸
if(node.previousSibling.nodeType != cnode.nodeType)
{
return perviousSiblingSameType(node.previousSibling , cnode);
}
// 節(jié)點類型相等則返回
else if(cnode.nodeType == node.previousSibling.nodeType)
{
return node.previousSibling ;
}
}
}
// 兼容火狐獲取一個節(jié)點的相同類型的下一個相鄰節(jié)點
function nextSiblingSameType(node , cnode)
{
// 為空直接返回null
if(node.nextSibling == null )
{
return null ;
}
else
{
// 節(jié)點類型不相等繼續(xù)遞歸
if(node.nextSibling.nodeType != cnode.nodeType)
{
return nextSiblingSameType(node.nextSibling , cnode);
}
// 節(jié)點類型相等則返回
else if(cnode.nodeType == node.nextSibling.nodeType)
{
return node.nextSibling ;
}
}
}
相關(guān)文章
javascript十個最常用的自定義函數(shù)(中文版)
如果不使用類庫或者沒有自己的類庫,儲備一些常用函數(shù)總是有好處的。2009-09-09
前端echarts tooltip展示多項自定義數(shù)據(jù)代碼示例
Echarts是一個基于JavaScript的開源圖表庫,提供了豐富的圖表類型,如折線圖、柱狀圖、餅圖、散點圖等,支持動態(tài)數(shù)據(jù)交互和自定義配置,這篇文章主要給大家介紹了關(guān)于前端echarts tooltip展示多項自定義數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下2024-09-09
微信小程序?qū)崿F(xiàn)移動端滑動分頁效果(ajax)
這篇文章主要為大家詳細介紹了微信小程序?qū)崿F(xiàn)移動端滑動分頁效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06

