求最后问题的解答
求最后问题的解答
求最后问题的解答
2014-12-31
/**
* Created by Administrator on 2016-09-04.
*/
function showdiv(obj){
initstatus();
var x = obj.parentNode;//摘要
//var y = x.nextSibling;//正文
var y = IceNextSiblingNode(x.nextSibling);
x.style.display = 'none';
y.style.display = 'block';
}
function hidediv(obj){
var x = obj.parentNode.parentNode;//正文的容器
//var y = x.nextSibling;//正文
var y = IcePreviousSiblingNode(x.previousSibling);
x.style.display = 'none';
y.style.display = 'block';
}
function IceNextSiblingNode(obj){
while (obj.nodeType != 1 ){
obj = obj.nextSibling;
}
return obj;
}
function IcePreviousSiblingNode(obj){
while(obj.nodeType !=1 ){
obj = obj.previousSibling;
}
return obj;
}
function initstatus(){
var contentList = document.querySelectorAll(".content");
var abstractList = document.querySelectorAll(".abstract");
for(var i=0; i<contentList.length; i++){
contentList[i].style.display = 'none';//隐藏所有文章的内容
//abstractList[i].style.display = 'block';
IcePreviousSiblingNode(contentList[i].previousSibling).style.display = 'block'//显示 全文按钮
}
}
举报