1

我有一个通过 ajax 请求创建并附加到页面的动态生成的表。当用户将鼠标悬停在每个单元格上时,我需要更改背景。(这不是一个 html 表 - 该表是通过 css 生成的,因此没有等...)。

到目前为止,我的代码如下。

$(document).on('hover', '.day_holder1a', function(){
    $(this).toggleClass('forum_hover');
});

我认为问题出在“this”并且它引用了 $(document) 但我的更改没有成功。

我已经删除了 toggleClass 中 forum_hover 之前的点,因为这是我的错误,应该检查我粘贴的代码。

4

2 回答 2

3

不,问题不在于this对象。

问题出.在您的 toggleClass 函数中

$(document).on('hover', '.day_holder1a', function(){
    $(this).toggleClass('forum_hover');
});

注意:而不是hover使用mouseenter

于 2012-07-06T10:24:41.073 回答
0

只需删除.toggleClass 功能。
阅读文档

于 2012-07-06T10:26:06.327 回答