jquery - 将鼠标悬停在一些 div 上并在 jquery 中显示另一个 div

标签 jquery html css

我希望当鼠标悬停在 (li.title) 上时,然后使用 jquery 显示下一个 (div.content)。 我测试了一些代码,但是当鼠标悬停在标题上时,只显示一个内容。

现在我能做什么?

我的 HTML 代码

<div class="posts">

<li class="title">
<a href="#">Title post</a>
</li>

<div class="content">
Content
</div>

</div>

<div class="posts">

<li class="title">
<a href="#">Title post</a>
</li>

<div class="content">
Content
</div>

</div>

<div class="posts">

<li class="title">
<a href="#">Title post</a>
</li>

<div class="content">
Content
</div>

</div>

最佳答案

将您的内容重命名为 content1、content2、content3 以查看不同的正文和代码:

$('.title').mouseover(function () {

    alert($(this).next('div').html());
});

然后你可以隐藏所有内容并显示正确的下一个内容

关于jquery - 将鼠标悬停在一些 div 上并在 jquery 中显示另一个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26552699/

相关文章:

javascript - 当我删除添加行 javascript 中的行时,行计数无法正常工作

javascript - 引导动态表单字段不起作用

html - 您将使用什么 CSS 功能在 2D 网格上显示高程?

iphone - 响应式 img 调整大小在 iPad 上不起作用

jquery - 滑动 div 停止并走得更远

javascript - 当我尝试通过 jquery 和 ajax 传递 css 代码时,它被删除

javascript - 切换溢出 - jQuery

html - iOS Safari <button disabled></button> 不禁用?

css - IE7 中标题和文本之间的巨大差距

javascript - bxslider 在移动设备中缩放