Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/474.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/2/jquery/80.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 Jquery图像悬停被卡住_Javascript_Jquery_Css - Fatal编程技术网

Javascript Jquery图像悬停被卡住

Javascript Jquery图像悬停被卡住,javascript,jquery,css,Javascript,Jquery,Css,我试图使jQuery悬停图像,但代码不能正常工作,它没有显示任何内容。 我粘贴我的代码来解释,我希望有人能帮我这个 gallery.html <html> <head> <title>Test</title> <link rel="stylesheet" href="style.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquer

我试图使jQuery悬停图像,但代码不能正常工作,它没有显示任何内容。 我粘贴我的代码来解释,我希望有人能帮我这个

gallery.html

<html>
 <head>
 <title>Test</title>
 <link rel="stylesheet" href="style.css" />
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 <script src="js/default.js"></script>
 </head>
 <body>
 <div class="gallery">
 <ul class="items">
  <ul>
     <li><span class="img_frame"><a href="img/s6300159.jpg"><img src="img/test1.jpg" /></a></span><div class="img_desc"><span>22</span></div></li>
     <li><span class="img_frame"><a href="img/s6300159.jpg"><img src="img/test1.jpg" /></a></span><div class="img_desc"><span>23</span></div></li>
     <li><span class="img_frame"><a href="img/s6300159.jpg"><img src="img/test1.jpg" /></a></span><div class="img_desc"><span>24</span></div></li>
  </ul>
 </ul>
 </div>
</body>
</html>
default.js

.gallery {overflow:hidden; width:1000px;}
.gallery .items { margin-bottom:50px; height:320px; }
.gallery .items li { position:relative; float:left;  width:290px; height:180px; margin-right:38px; margin-bottom: 30px; }
 .gallery .items li img { width:277px; height:165px; }

 .img_desc {
position: absolute;
    display: block;
    top: 10px; 
text-shadow: 1px 1px 0 #ffffff;
color: #262626;  
background: url(img/benefits_on.png) repeat;
width: 36px;
right: 5px;
text-align: center;
    }


    .img_frame {
    margin-top:3px;
     padding:1px;
     display:inline-block;
     line-height:0px;
     background:#fff;
     border:1px solid #ccc;
      }

    .img_frame img {
     padding:1px;
     border:4px solid #f2f1f0;
    }
    .img_frame a { display:block; }

    .hover_image { background:url("img/preview_image.png") center center no-repeat; }
<!-- Image hover effect -->
function image_hover(frame){
var link_content = jQuery(frame).find('a[href^=http], a[href*=www], a[href=#], a[href$=html], a[href$=php], a[href$=asp], a[href$=htm], a[href$=shtml], a[href$=aspx]');
var image_content = jQuery(frame).find('a[href$=jpg], a[href$=png], a[href$=gif], a[href$=jpeg]');
var video_content = jQuery(frame).find('a[href*=vimeo], a[href*=youtube], a[href*=swf], a[href*=flv], a[href*=avi], a[href*=mov], a[href*=mpg]');

link_content.addClass("hover_link");
image_content.removeClass("hover_link").addClass("hover_image");
video_content.removeClass("hover_link").addClass("hover_video");

jQuery(frame).find("a > img").hover(
    function() {
        if(!jQuery(this).parent().hasClass("no_hover")){
            jQuery(this).stop().animate({"opacity": ".6"}, "400");
        }
    },
    function() {
        jQuery(this).stop().animate({"opacity": "1"}, "400");
});

jQuery(frame).children("a.no_hover").removeClass("hover_image");
return false;
}

jQuery(function(){

image_hover('.img_frame');
 });

功能图像悬停(帧){
var link_content=jQuery(frame).find('a[href^=http]、a[href*=www]、a[href=#]、a[href$=html]、a[href$=php]、a[href$=asp]、a[href$=htm]、a[href$=shtml]、a[href$=aspx]);
var image_content=jQuery(frame).find('a[href$=jpg]、a[href$=png]、a[href$=gif]、a[href$=jpeg]);
var video_content=jQuery(frame).find('a[href*=vimeo]、a[href*=youtube]、a[href*=swf]、a[href*=flv]、a[href*=avi]、a[href*=mov]、a[href*=mpg]);
link_content.addClass(“hover_link”);
image_content.removeClass(“hover_link”).addClass(“hover_image”);
视频内容.removeClass(“悬停链接”).addClass(“悬停视频”);
jQuery(frame).find(“a>img”).hover(
函数(){
if(!jQuery(this).parent().hasClass(“无悬停”)){
jQuery(this.stop().animate({“不透明”:.6”},“400”);
}
},
函数(){
jQuery(this.stop().animate({“opacity”:“1”},“400”);
});
jQuery(frame).children(“a.no_hover”).removeClass(“hover_image”);
返回false;
}
jQuery(函数(){
图像悬停('.img_frame');
});

您希望实现什么样的悬停效果?在我的例子中,它向我展示了一些发光的边框或类似的东西,因为它降低了不透明度,背景正在向上拉起。如果这是您想要的,您可能在
.hover\u image
类的图像位置上犯了错误。尝试为该类设置背景色,如

.hover_image { background:#ff0000 url("img/preview_image.png") center center no-repeat; }

您可能会得到与我完全相同的效果。

您能缩小问题范围并编辑帖子以显示较少的代码吗?我在default.js(已解决)中的错误您能准确解释一下您在寻找什么以及您是如何解决的吗?