<script>
$(document).ready(function(){
$("li.start").next().slidetoggle("li");
});
</script>
</head>
<body>
<div style="width:500px;" class="siblings">
<ul>ul (parent)
<li class="start">li (sibling with class name "start")</li>
<li>li (the next sibling of li with class name "start")</li>
</ul>
<ul>ul (parent)
<li class="start">li (sibling with class name "start")</li>
<li>li (the next sibling of li with class name "start")</li>
</ul>
</div>
此代码无效。我需要对所有具有父子关系的元素使用幻灯片切换
答案 0 :(得分:0)
我现在意识到我失踪了this
。它现在有效。
我改变了:
$(document).ready(function(){
$("li.start").next().slidetoggle("li");
});
到:
$(document).ready(function(){
$(".parent").click(function(){
$(this).next('li').slideToggle(250);
});
});