jQuery - 鼠标悬停在更改文本上 [英] jQuery - On Mouse Over Change Text

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

问题描述

 < span id =change> 
这里的东西
< / span>

< script>
$(#change)。on(mouseover,function(){
$('#change')。text(This is the new html);
} );
< / script>

以下不起作用,作为jQuery noob,我不知道为什么。

解决方案

更改此:

  <脚本> 
$(#change)。on(mouseover,function(){
$('#change')。text(This is the new html);
} );
< / script>

因为你没有引用任何东西。试试这个:

 < script> 
$(document).ready(function(){
$(#change)。mouseover(function(){
$('#change')。text(This is新的html);
});
});
< / script>

好的,小提琴还有另一个错误。你没有在左上角选择任何jQuery版本。更新后,代码完美运行,并从中得出结论,您可能未链接到您网站的脚本。



尝试链接脚本

文件放置在布局(网站)的头部部分中。现在: http://jsfiddle.net/afzaal_ahmad_zeeshan/HMhVn/3/



我已经更新了它,现在它完美运行:)


<span id="change">
    Stuff In Here
</span>

<script>
$("#change").on("mouseover", function () {
     $('#change').text("This is the new html");
});
</script>

The following doesn't work, as a jQuery noob, I'm not sure why.

解决方案

Change this:

<script>
 $("#change").on("mouseover", function () {
   $('#change').text("This is the new html");
 });
</script>

Because you are not referencing anything. Try this:

<script>
  $(document).ready(function () {
    $("#change").mouseover(function () {
      $('#change').text("This is the new html");
    });
  });
</script>

Well, there was another error in the fiddle. You had not selected any jQuery version in the upper left corner. After updating, the code worked perfectly, and from this I concluded that you might have not linked the script in your website.

Try linking the script file in the head section of your layout (website)

Here have a look now: http://jsfiddle.net/afzaal_ahmad_zeeshan/HMhVn/3/

I have updated it, and it runs perfectly now :)

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

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