【发布时间】:2014-11-14 10:34:49
【问题描述】:
当鼠标悬停在其他文本上时,我想更改 div 的文本。
如何使用 JavaScript 或 jQuery 来实现?
<a href="#">change your div text</a>
<div class="original">
<p class="old">this is my first quesstion on stackoverflow and i hope to be solved</p>
</div>
<p class="new"> the new text i want to add</br>
i will use big text really and i want to change it</p>
当悬停在上面的链接上时,如何将旧的 p 类替换为新的 p 类,当悬停停止时如何让它返回到原始类?
【问题讨论】:
-
这也有效 4 me $('a').hover(function () { $('.old').hide(); $('.new').show(); }, 函数 () { $('.old').show(); $('.new').hide(); });使用 css .new { 显示:无; } 我不知道为什么那个帖子被删除了??我是堆栈溢出的新手?但这也是同样的事情,如何在新文本中停留一段时间(制作副本或其他)?它会自动消失,我无法访问新文本?
标签: javascript jquery html