日期:2014-05-16 浏览次数:20345 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>test </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <script src="js/jquery-1.7.js"></script> <script type="text/javascript"> $(".clicko").click(function(){ $(this).parent().find('.test>li').show(); }) </script> <style type="text/css"> .listimages { list-style-type:none; font-size:16px; float:left; margin:0; } .list1 { list-style-type:none; background:url(images/2.jpg) no-repeat top center; padding:10px 0 0 0px; margin:0; display:none; } .test li { display:none; } .sp { float:left; display:inline; width:14px; font-size:14px; word-wrap:break-word; word-break:nomal; margin:0 10px 0 0; } </style> </head> <body> <ul> <li class="listimages"> <div style="width:1em;float:left;font-weight:bold;cursor:pointer" class="clicko">流逝岁月</div> <ul class="test"> <li class="list1 sp"><a href="#">作风友情</a></li> <li class="list1 sp"><a href="#">告诉你啊</a></li> </ul> </li> <li class="listimages"> <div style="width:1em;float:left;font-weight:bold;cursor:pointer" class="clicko">学不思路</div> <ul class="test"> <li class="list1 sp">奇峰异次</li> <li class="list1 sp">劳技课从</li> </ul> </li> <li class="listimages"> <div style="width:1em;float:left;font-weight:bold;cursor:pointer" class="clicko">走路风情</div> <ul class="test"> <li class="list1 sp">奇峰异次</li> <li class="list1 sp">劳技课从</li> </ul> </li> <li class="listimages"> <div style="width:1em;float:left;font-weight:bold;cursor:pointer" class="clicko">四期符合</div> <ul class="test"> <li class="list1 sp">奇峰异次</li> <li class="list1 sp">劳技课从</li> </ul> </li> </ul> </body> </html>
<ul class="test"> <li class="list1 sp">奇峰异次</li> <li class="list1 sp">劳技课从</li> </ul>
.list1 { list-style-type:none; background:url(images/2.jpg) no-repeat top center; padding:10px 0 0 0px; margin:0; display:none; } .test li { display:none; }
------解决方案--------------------
你写少了加载函数$(function{})或$(document).ready(){}
$(function(){
$(".clicko").click(function(){
$(this).parent().find('.test>li').show();
});
});
------解决方案--------------------
$(document).ready(function(){ $(".clicko").toggle(function(){ $(".test>li").hide(); $(this).parent().find('.test>li').show(); },function(){ $(".test>li