标签:ntb span next head 内容 utf-8 function round splay
###
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> .headcolor{ background-color: gray; height: 100px; } .bodycolor{ background-color: green; width: 50px; } .hide{ display: none; } .content1{ color: red; } </style> </head> <body style="margin: 0"> <div class="headcolor">111</div> <div> <div> <div id="i1" class="bodycolor" onclick="hide(‘i1‘)">菜单一</div> <div class="hide"> <div>内容1</div> <div>内容2</div> <div>内容3</div> </div> </div> <div> <div id="i2" class="bodycolor" onclick="hide(‘i2‘)">菜单二</div> <div class="hide"> <div>内容1</div> <div>内容2</div> <div>内容3</div> </div> </div> <div> <div id="i3" class="bodycolor" onclick="hide(‘i3‘)">菜单三</div> <div class="hide"> <div>内容1</div> <div>内容2</div> <div>内容3</div> </div> </div> </div> <script> function hide(nid) { var d = document.getElementById(nid); var item_list = d.parentElement.parentElement.children; console.log(d); for(var i=0;i<item_list.length;i++){ item_list[i].children[1].classList.add(‘hide‘); } d.nextElementSibling.classList.remove("hide") } // function hide(nid) { // var d = document.getElementById(nid); // // console.log(d); // d.nextElementSibling.classList.remove(‘hide‘); // } </script> </body> </html>
###
标签:ntb span next head 内容 utf-8 function round splay
原文地址:http://www.cnblogs.com/lwsup/p/7427435.html