-
// 顯示函數(shù) function showdiv(obj) { var x=obj.parentNode; var y=x.nextSibling; if(y.nodeType!=1){ y=y.nextSibling; } x.style.display="none"; y.style.display="block"; } // 隱藏函數(shù) function hidediv(obj) { var y=obj.parentNode.parentNode; var x=y.previousSibling; if(x.nodeType!=1){ y=y.previousSibling; } y.style.display="none"; x.style.display="block"; }查看全部
-
瀏覽器兼容問題解決, 為了避免查找的previousSibling,nextSibling是空白節(jié)點(diǎn),判斷其nodeType 1.if(x.nodeType!=1){ x=x.previousSibling; } 2.function getNextElement(node){ if(node.nextSibling.nodeType == 1){ //判斷下一個(gè)節(jié)點(diǎn)類型為1則是“元素”節(jié)點(diǎn) return node.nextSibling; } if(node.nextSibling.nodeType == 3){ //判斷下一個(gè)節(jié)點(diǎn)類型為3則是“文本”節(jié)點(diǎn) ,回調(diào)自身函數(shù) return getNextElement(node.nextSibling); } nodeType如果等于2表示為屬性節(jié)點(diǎn)查看全部
-
nextSibling:返回某個(gè)元素之后緊跟的元素(處于同一樹層級(jí)) previousSibling:返回某節(jié)點(diǎn)之前緊跟的節(jié)點(diǎn)(處于同一樹層級(jí)) parentNode 父節(jié)點(diǎn)查看全部
-
<script type="text/javascript"> $(document).ready(function(){ $("#strHref").toggle(function(){ $(this).text("收起"); $("#hpn").show(1000);//隱藏改成顯示$是查找 },function(){ $(this).text("更多選項(xiàng)+"); $("#hpn").hide(1000);//隱藏改成顯示$是查找查看全部
-
1.setTimeout('subh()',30);函數(shù)要用引號(hào)括起 2.return是退出函數(shù) 3.在函數(shù)subh()里,如果在else里不寫document.getElementById("pn").style.display = "none";,會(huì)發(fā)現(xiàn)div#pn不能完全收起來,最后會(huì)留一定的高度查看全部
-
定時(shí)展開和收起廣告效果: 1.增加高度函數(shù)并循環(huán)調(diào)用函數(shù)(展開效果) function addH(){ if(h<300){ h+=5; documentt.getElementById("pn").style.height=h+"px"; }else{ return; } setTimeout("addH()",30); } 2.收起效果 function subH(){ if(h>0){ h-=5; documentt.getElementById("pn").style.height=h+"px"; }else{ documentt.getElementById("pn").style.display="none"; return; } setTimeout("subH()",30); } 3.函數(shù)調(diào)用 window.onload=function (){ addH(); setTimeout("subH()",3000); }查看全部
-
先設(shè)置盒子的框架,首先是隱藏層,然后設(shè)置下拉層,最后設(shè)置鼠標(biāo)停留5秒后收起查看全部
-
用到的函數(shù)總結(jié)查看全部
-
document.getElementById("strHref").href = "javascript:hidediv();";//對(duì)應(yīng)收起事件 document.getElementById("strHref").href = "javascript:showdiv();";//對(duì)應(yīng)隱藏事件 [ 查看全文 ]查看全部
-
function showdiv() {//展開函數(shù) document.getElementById('hpn').style.display='block'; document.getElementById('strHref').innerHTML='收起-'; document.getElementById("strHref").href="javascript:hidediv();"; }查看全部
-
制作思路查看全部
-
該函數(shù)實(shí)現(xiàn)查看全部
-
鏈接做點(diǎn)擊事件既可以實(shí)現(xiàn)查看全部
-
$(function(){ $("#strHref").toggle(function(){ $(this).text("收起-"); $("#hpn").show(1000); },function(){ $(this).text("更多+"); $("#hpn").hide(1000); }); });查看全部
-
<script type="text/javascript"> //增加高度函數(shù)addH() var h = 0; function addh() { if(h < 120){ h+=2; document.getElementById('pn').style.height = h +'px'; }else{ return; } setTimeout('addh()',30); } //網(wǎng)頁加載完畢時(shí),調(diào)用增加高度函數(shù)addH(),等待5秒鐘后調(diào)用減少高度函數(shù)subh()。 window.onload = function(){ addh(); setTimeout('subh()',5000); } // 減少高度函數(shù)subH() function subh() { if(h > 0){ h-=2; document.getElementById('pn').style.height = h +'px'; }else{ return; document.getElementById('pn').style.display = 'none'; } setTimeout('subh()',30); } </script>查看全部
舉報(bào)
0/150
提交
取消