2013-10-05 116 views
-1

我創造一個迷宮,不知道爲什麼懸停不工作 會很高興的任何幫助懸停不工作

$('.wall') 
.bind('mouseenter', function() { 
    $(this).css({ 
     'background-color': 'green' 
    }); 
}) 

這裏是小提琴鏈接:

http://jsfiddle.net/uqcLn/6/

+0

你必須包括jQuery庫使用其功能。 – Musa

+0

您沒有包含jQuery,只要添加它就可以工作 - http://jsfiddle.net/uqcLn/7/。在將來嘗試檢查您的瀏覽器的控制檯的錯誤:http://stackoverflow.com/questions/4743730/what-is-console-log-and-how-do-i-use-it – Joe

+0

請參閱http://jsfiddle.net/vYt9Q/1/ –

回答

2

在jsfiddle中使用此功能:

in html add this:

<script type="text/javascript" src="http://codeorigin.jquery.com/jquery-1.10.2.min.js"></script> 

和腳本做到這一點:

$(document).ready(function(){ 
    $(document).on("mouseenter",".wall",function(){ 
    $(this).css({ 
      'background-color': 'green' 
     }); 
    }); 
    $(document).on('mouseleave',".wall", function() { 
     $(this).css({ 
      'background-color': '' 
     }); 
    }); 
});