jquery练习之左侧菜单
Posted jintian
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jquery练习之左侧菜单相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> .outer height: 1000px; width: 100%; .menu float: left; background-color: beige; width: 30%; height: 500px; .content float: left; background-color: rebeccapurple; width: 70%; height: 500px; .title background-color: aquamarine; line-height: 40px; .hide display: none; </style> </head> <body> <div class="outer"> <div class="menu"> <div class="item"> <div class="title" onclick="show(this)">菜单一</div> <div class="con"> <div>111</div> <div>111</div> <div>111</div> </div> </div> <div class="item"> <div class="title" onclick="show(this)">菜单二</div> <div class="con hide"> <div>222</div> <div>222</div> <div>222</div> </div> </div> <div class="item"> <div class="title" onclick="show(this)">菜单三</div> <div class="con hide"> <div>333</div> <div>333</div> <div>333</div> </div> </div> </div> <div class="content"></div> </div> <script src="jquery-3.1.1.js"></script> <script> function show(self) $(self).next().removeClass("hide"); $(self).parent().siblings().children(".con").addClass("hide"); </script> </body> </html>
以上是关于jquery练习之左侧菜单的主要内容,如果未能解决你的问题,请参考以下文章