• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

鼠标悬停时更改内容,鼠标移除后恢复

用户头像
it1352
帮助1

问题说明

我有一些带有一些文本的DIV,想要在鼠标悬停时更改文本,并在mouSEO((Search Engine Optimization))ut后恢复文本。如下所示。

I have a DIV with some text, want to change the text on mouSEO((Search Engine Optimization))ver, and restore the text after mouSEO((Search Engine Optimization))ut. Like following.

< div class =test> MouSEO((Search Engine Optimization))ut的文本< / div>

< div class =test>鼠标悬停的文本< / div>

我尝试按照以下方式执行此操作,但鼠标悬停时文本更改但鼠标悬停后未恢复:

I tried to do it like following, but the text change when mouSEO((Search Engine Optimization))ver but not restore after mouSEO((Search Engine Optimization))ut:

$(".test").hover(
  function() {
    var $original = $(this).clone();
    $(this).html("Text of MouSEO((Search Engine Optimization))ver");
  },
  function() {
    $(this).html($original);
  }
);

正确答案

#1
$("div.test").hover(

  function () {
       originalText=$(this).text();
    $(this).text('New Text');
  }, 
  function () {
    $(this).text(originalText);
  }
      );

现场演示

Live Demo


这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcachgh
系列文章
更多 icon
同类精品
更多 icon
继续加载