我试图添加一些功能时,徘徊在2048瓷砖。每一个值n的瓷砖都有一个类“tile”。
对于基本的“平铺-2”瓷砖,我有一个悬停功能:
<script>
$( ".tile-2" ).hover(
function(){
alert("in!");
}, function() {
alert("out!");
}
);
</script>但是什么都没有发生,我不相信悬停是被注册的,我不知道为什么。
我的实现可以在:http://kpscript.github.io/PCN-Embark-2048/上看到
“Time-2”div可以在以下位置看到: html.body.container.game-container.tile-container.tile-2.。
当然,我计划用悬停来做更多非琐碎的事情,但现在我甚至无法得到提醒。
发布于 2014-03-29 20:59:27
就像这样,对我有用.
$("body").on('mouseenter', '.tile-2', function () {
alert("in!");
}).on('mouseleave', '.tile-2', function () {
alert("out!");
});发布于 2014-03-29 20:44:55
我认为您使用ajax加载html,这应该有效。
<script>
$( "body" ).on('hover','.tile-2',
function(){
alert("in!");
}, function() {
alert("out!");
}
);
;)
发布于 2014-03-29 23:15:09
在页面上呈现元素之前,您正在尝试将事件绑定到元素。等它上膛。
$(document).ready({
$( ".tile-2" ).hover(
function(){
alert("in!");
}, function() {
alert("out!");
}
);
});https://stackoverflow.com/questions/22736618
复制相似问题