本文实例讲述了jquery实现的树形目录。分享给大家供大家参考。具体实现方法如下:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> .st_tree ul li { font-size:13px; color:#222; line-height:18px; cursor:pointer; list-style:none; background:url(st_folder.gif); background-repeat:no-repeat; padding:0 0 3px 20px; } </style> </head> <body> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".ul").hide(); }) $(document).ready(function() { $("#li1").click(function() { $("#ul1").toggle(); }); }); $(document).ready(function() { $("#li2").click(function() { $("#ul2").toggle(); }); }); $(document).ready(function() { $("#li3").click(function() { $("#ul3").toggle(); }); }); </script> <div class="st_tree"> <ul> <li ><a href="#" >一级目录1</a></li> <li id="li1"><a href="#" >一级目录2</a></li>新闻热点
疑难解答