您的位置:首页 > Web前端 > JavaScript

原生Js获取某个节点后面的第一个标签

2015-01-16 11:05 316 查看
nextSlbling属性 获取某个节点后面的第一个节点(可能是标签 文本)

  判断获取的节点是否为标签节点还是文本节点

window.onload=function(){
var pagecount={$page_count};
document.getElementById('firsts').setAttribute('class','disabled');
document.getElementById('before').setAttribute('class','disabled');
var current=document.getElementById('before').nextSibling;
while(current.nodeType != 1){      根据nodeType判断节点属性
current=current.nextSibling;
}
current.setAttribute('class','current');
if(pagecount==1){
document.getElementById('next').setAttribute('class','disabled');
document.getElementById('last').setAttribute('class','disabled');
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: