我是 j Query 的新手。我正在尝试在 id 为“#employee”的 div 中打开与每个列表项相关的内容。id "#details" 应该一次打开 1 个项目并隐藏其他项目。我试图自己解决这个问题,但由于我的知识很少,我无法做到。
<div>
<div class="details">
<div id="employee1"><h2>Employee 1</h2><p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature </p></div>
</div>
<div class="details">
<div id="employee2"><h2>Employee 2</h2><p>Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum</p></div>
</div>
<div class="details">
<div id="employee3"><h2>Employee 3</h2><p>Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum</p></div>
</div>
<div class="details">
<div id="employee4"><h2>Employee 4</h2><p>Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum</p></div>
</div>
<div class="thumbs">
<ul>
<li id="employee1">Employe 1</li>
<li id="employee2">Employe 2</li>
<li id="employee3">Employe 3</li>
<li id="employee4">Employe 4</li>
</ul>
</div>
</div>
$(document).ready(function () {
$("li").click(function () {
var divname = this.html();
$("#employee").show("slow").siblings().hide("slow");
});
});