jquery代码如下:
<script>
$(".text").hover(function(){
var inde=$(this).index(".text");
$(".text .caption a").eq(inde).show();
$(".text .caption h3").eq(inde).hide();
$(".text .caption h5").eq(inde).hide();
},function(){
var inde=$(this).index(".text");
$(".text .caption a").eq(inde).hide();
$(".text .caption h3").eq(inde).show();
$(".text .caption h5").eq(inde).show();
});
</script>
效果:
当点击text类时,出现上方所设置的效果。注意:var inde=$(this).index(".text");和eq(inde).,这是为了实现hover事件匹配到当前鼠标移动的text类上。