Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在鼠标悬停时更改DIV内容_Javascript_Mouseover - Fatal编程技术网

Javascript 在鼠标悬停时更改DIV内容

Javascript 在鼠标悬停时更改DIV内容,javascript,mouseover,Javascript,Mouseover,我有一个用于内容显示的现有脚本。当前,当你点击一个链接时,它会工作。是否可以将其修改为鼠标悬停而不是单击 这是我的: HTML: 只需将“单击”更改为“鼠标悬停” 你也可以用鼠标。有关更多说明,请参阅链接 只需将“单击”更改为“鼠标悬停” 你也可以用鼠标。有关更多说明,请参阅链接 对。替换为单击 对。替换为单击 您可以将单击替换为鼠标悬停: 您可以将单击替换为鼠标悬停: 是,只需替换。单击。悬停或。鼠标悬停: 在这里您可以看到它是如何工作的。是的,只需替换。单击.hover或.mouseover

我有一个用于内容显示的现有脚本。当前,当你点击一个链接时,它会工作。是否可以将其修改为鼠标悬停而不是单击

这是我的:

HTML:

只需将“单击”更改为“鼠标悬停”

你也可以用鼠标。有关更多说明,请参阅链接

只需将“单击”更改为“鼠标悬停”

你也可以用鼠标。有关更多说明,请参阅链接

对。替换为单击

对。替换为单击

您可以将单击替换为鼠标悬停:

您可以将单击替换为鼠标悬停:


是,只需替换。单击。悬停或。鼠标悬停:


在这里您可以看到它是如何工作的。是的,只需替换。单击.hover或.mouseover:


在这里,您可以看到它是如何工作的。

如果使用最新版本的jQuery SyntaxError,您的代码会出现一些不推荐使用的函数问题并显示错误:使用/@指示sourceMappingURL pragmas不推荐使用。用//代替

将其更改为:

$(document).ready(function() {
    $('#1, #2, #3').mouseover(function(evt) {
        $('.content').html('This is a text example' + evt.currentTarget.id);
    });
});

如果使用最新版本的jQuery SyntaxError,您的代码会出现一些不推荐使用的函数问题并显示错误:使用/@表示不推荐使用sourceMappingURL pragmas。用//代替

将其更改为:

$(document).ready(function() {
    $('#1, #2, #3').mouseover(function(evt) {
        $('.content').html('This is a text example' + evt.currentTarget.id);
    });
});

改变点击鼠标的方式?谢谢@FarhadJabiyev,现在我觉得自己很愚蠢。那很容易。但是谷歌搜索把我弄糊涂了。什么时候使用.mouseover和.hover?.hover函数接受两个函数参数,一个用于mouseenter事件,另一个用于mouseleave事件。谢谢@FarhadJabiyev我会读到更多关于这方面的内容。很高兴能帮上忙。祝你好运。点击鼠标切换到鼠标上方?谢谢@FarhadJabiyev,现在我觉得自己很愚蠢。那很容易。但是谷歌搜索把我弄糊涂了。什么时候使用.mouseover和.hover?.hover函数接受两个函数参数,一个用于mouseenter事件,另一个用于mouseleave事件。谢谢@FarhadJabiyev我会读到更多关于这方面的内容。很高兴能帮上忙。祝你好运
$( document ).ready(function() {
    $('#1').mouseover(); 
});

$('#1').mouseover(function() {
  $('.content').html('This is a text example 1');
});

$('#2').mouseover(function() {
  $('.content').html('This is a text example 2');
});

$('#3').mouseover(function() {
  $('.content').html('This is a text example 3');
});
 $( document ).ready(function() {
   $('#1').click(); 
 });

 $('#1').mouseover(function() {
  $('.content').html('This is a text example 1');
});

$('#2').mouseover(function() {
  $('.content').html('This is a text example 2');
 });
 $('#3').mouseover(function() {
  $('.content').html('This is a text example 3');
});
$( document ).ready(function() {
$('#1').mouseover(); 
});

$('#1').mouseover(function() {
$('.content').html('This is a text example 1');
});

$('#2').mouseover(function() {
$('.content').html('This is a text example 2');
});

$('#3').mouseover(function() {
$('.content').html('This is a text example 3');
}); 
$( document ).ready(function() {
    $('#1').click(); 
});

$('#1').hover(function() {
  $('.content').html('This is a text example 1');
});

$('#2').hover(function() {
  $('.content').html('This is a text example 2');
});

$('#3').hover(function() {
  $('.content').html('This is a text example 3');
});
$(document).ready(function() {
    $('#1, #2, #3').mouseover(function(evt) {
        $('.content').html('This is a text example' + evt.currentTarget.id);
    });
});