使用JQuery更改悬停上的文本 [英] Change text on Hover using JQuery

查看:62
本文介绍了使用JQuery更改悬停上的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将导航元素从'ME'更改为< ME>使用JQuery悬停。以下是我想要的:
JSBin示例



但是,它永久隐藏了我的原始文本。有没有人有一个想法,我做错了什么? (我一般对JQuery / JS超级新手)

解决方案

DEMO

试试这个。我编辑了您的代码。

  $(function(){
var text;
$(# topnav li).hover(
function(){
text = $(this).find(a)。text();
$(this).find(a ).text($(this).attr('full'));
},
function(){
$(this).find(a)。text文字);
}
);
});

希望这有助于
谢谢

I am trying to change a navigation element from 'ME' to <ME> on hover using JQuery. Here's what I'm trying: JSBin example

However, it's permanently hiding my original text. Does anyone have an idea as to what I'm doing wrong? (I'm super new to JQuery/ JS in general)

解决方案

DEMO

Try this. I have edited your code

$( function() {
  var text;
  $("#topnav li ").hover(
    function () {
      text=$(this).find("a").text();
     $(this).find("a").text($(this).attr('full'));
    },
    function () {
       $(this).find("a").text(text);
    }
  );
});

Hope this helps Thank you

这篇关于使用JQuery更改悬停上的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆