【发布时间】:2012-10-17 20:03:27
【问题描述】:
这是我在 jQuery/ajax 中的第一次尝试,我遇到了麻烦。
这是我的 HTML 代码...
<div id="level_1_description" class="level_description wrapper">
<h2><a href="#">Food</a></h2>
<strong>..to have a good taste</strong>
<p class="description"><span class="text">You want to eat healthy food.</span></p>
</div>
...以及动画悬停动作的脚本:显示/隐藏 .level_description 容器中的 .description 元素。
<script>
$('.level_description').hover(function(){
$('.description').animate({height:$('.text').height()},100);
},
function () {
$('.description').animate({height:1},100);
}
);
</script>
工作正常,但我不知道如何与第二个包装器(#level_2_description)分开,女巫具有相同的元素(.level_description,.description)
我想用这样的东西? :
...
$(this.'.description').animate({
height:$(this.'.text').height()
...
【问题讨论】:
标签: jquery ajax hover jquery-animate jquery-hover