Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.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滚动(使用jquery)_Javascript_Jquery_Rollover - Fatal编程技术网

Javascript 需要对内的图像进行div滚动(使用jquery)

Javascript 需要对内的图像进行div滚动(使用jquery),javascript,jquery,rollover,Javascript,Jquery,Rollover,好吧,我有一些独特的问题;首先,我的jquery不起作用;我很可能没有将它正确地放在html中,所以我将抛出大量代码来查看 基本上,当div类被滚动时,我需要将滚动类图像更改为其悬停状态(我有一些css将div类显示更改为block),好的,下面是html <div id="header"> <div class="home" id="home" ><a href="index.html"><p><img src="images/home-c

好吧,我有一些独特的问题;首先,我的jquery不起作用;我很可能没有将它正确地放在html中,所以我将抛出大量代码来查看

基本上,当div类被滚动时,我需要将滚动类图像更改为其悬停状态(我有一些css将div类显示更改为block),好的,下面是html

<div id="header">
<div class="home" id="home" ><a href="index.html"><p><img src="images/home-crown.png" class="rollover" width="100px" /></p></a></div>
真的很沮丧,因为我尝试了多种解决方案;任何帮助都将不胜感激;这可能是一些愚蠢的事情:P

现在我只是想让图像滚动(至少) 我真的想在翻滚div时激活翻滚(home div)

试试这个

$("img.rollover").hover(
   function(){
      $(this).attr("src","images/home-crown-hover.png");
   },
   function(){
      $(this).attr("src","images/home-crown.png");
   }
);

你不能只做属性
$(this.attr(“src”,“home crown.png”)和反之亦然versa@Daniel在哪里?(就像在什么代码之后?)类似的东西应该可以工作,只是不行,我想我会翻遍代码…我错了,我忘了在url中包含
图像/
部分;很好,谢谢你的帮助,这一定是我在代码的长区域的错误
$(document).ready(function(){

 $("img.rollover").hover(
      function() 
        {this.src = this.src.replace("images/home-crown.png","images/home-crown-hover.png");},
      function() 
        {this.src = this.src.replace("images/home-crown-hover.png","images/home-crown.png");}
 ); 
});
$("img.rollover").hover(
   function(){
      $(this).attr("src","images/home-crown-hover.png");
   },
   function(){
      $(this).attr("src","images/home-crown.png");
   }
);