小编rsc*_*man的帖子

如何将jquery效果应用于嵌套元素?

我正在开发一个简单的常见问题解答页面,该页面将显示/隐藏点击问题的答案.它在使用p元素时工作正常,除了任何嵌套的ul元素都没有被隐藏之外没有别的.嵌套元素是否必须单独调用?为什么效果不作为p标签的一部分应用于它?谢谢您的帮助.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> 

 <script language="javascript" type="text/javascript">

$(document).ready(function () {
    $(".answer").hide();
    $("a.question").click(function () {
      $(this).next(".answer").slideToggle(300);
      return false;
    });
 });
</script> 
<div id="body"> 
<ul style="list-style: none;"> 
<li><a class="question" href="#">How do I log in to email?</a> 
<p class="answer">
    <ul>
        <li>Open your favorite internet browser to <a href="https://email.school.edu">email.school.edu</a>.</li>
        <li>Use your school username and the password given to you by ITS.</li>
        <li>You will be required to change your password immediately.</li>
    </ul>
</p> 
</li> 
<li><a class="question" href="#">Is my email password the same as my school …
Run Code Online (Sandbox Code Playgroud)

jquery

0
推荐指数
1
解决办法
294
查看次数

标签 统计

jquery ×1