Javascript hover()事件在我的情况下未触发

Javascript hover()事件在我的情况下未触发,javascript,jquery,css,Javascript,Jquery,Css,我错过什么了吗?我想悬停以缩小并使用css对图片进行完整预览。您忘了将jQuery包含到小提琴中 你的代码运行良好 $(document).ready(function(){ $('.cell').hover(function(){ $('this').css('background-size','cover'); }); }); 这是工作代码。您没有包括Jquery <script src="//ajax.googleapis.com/ajax/libs/jquery

我错过什么了吗?我想悬停以缩小并使用css对图片进行完整预览。

您忘了将jQuery包含到小提琴中

你的代码运行良好

$(document).ready(function(){
  $('.cell').hover(function(){
    $('this').css('background-size','cover');
  });
});

这是工作代码。您没有包括Jquery

 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>

$(document).ready(function(){
  $('.cell').hover(function(){
    alert('hover work');
  });
});
</script>

    <div class="cell" style="width: 345.53px; height: 210.53px; 

    background-image: 
     url(https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-prn1/1521894_10151755196011682_1359230168_n.jpg);  

   position: absolute;-webkit-transition: top 0.5s, left 0.5s; 

   transition: top 0.5s, left 0.5s;" data-delay="2" 
   data-height="200" data-width="331" data-state="move" id="2-2"></div>
这项工作很好:

删除$'this'中的单个报价。要立即更改$this,它可以正常工作。

工作解决方案:

如前所述,您不应该在$this中有单个报价。
另外,在这个示例中,我添加了一个mouseout函数来重置背景大小。

您忘了将jQuery库包含在
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>

$(document).ready(function(){
  $('.cell').hover(function(){
    alert('hover work');
  });
});
</script>

    <div class="cell" style="width: 345.53px; height: 210.53px; 

    background-image: 
     url(https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-prn1/1521894_10151755196011682_1359230168_n.jpg);  

   position: absolute;-webkit-transition: top 0.5s, left 0.5s; 

   transition: top 0.5s, left 0.5s;" data-delay="2" 
   data-height="200" data-width="331" data-state="move" id="2-2"></div>
$(document).ready(function(){
  $('.cell').hover(function(){
    $(this).css('background-size','cover');
  });
});