我使用名爲「Spritely」的JS插件來爲背景圖像添加動畫。一切正常(背景正在移動)。但是當點擊一個div(sprite)時,我無法獲得一個被激活的函數。Spritely div .click不工作
(我有script.js,jquery和spritely包含在裏面)。
HTML只是2的div(#container的和#hills)
CSS
#container
{
width:100%;
height:100%;
margin-left:auto;
margin-right:auto;
background-image:url(clouds.jpg);
background-repeat:repeat-x;
z-index:-3;
position:absolute;
}
#hills
{
width:100%;
height:250px;
background-image:url(hills.png);
background-repeat:repeat-x;
background-position:bottom;
z-index:1;
position:absolute;
bottom:0px;
}
的JavaScript
$(document).ready(function() {
$(hills).click(function(){
alert("hey");
});
});
var hills;
$(document).ready(function(){
var hills = document.getElementById('hills');
$(hills).pan({fps: 30, speed: 2, dir: 'left'});
});