【发布时间】:2013-02-19 04:29:37
【问题描述】:
下面给出的代码示例:
(function (window, document) {
$('.rating_title_container').parents('.item_row_def').hover(function() {
setTimeout(function() {
system.console('Worked');
}, 1000);
});
})(window, document);
我对 JS、jQuery 还很陌生。谁能解释我在这里缺少什么? 在http://jsfiddle.net/p7gBy/5/发布代码
HTML
<table>
<thead>
<tr>
<th class="item_row_def" onclick="sort(3);">
<table class="col-header">
<tbody>
<tr>
<td>
<h2 class="header_title rating_title_container">Rating</h2>
</td>
</tr>
</tbody>
</table>
</th>
</tr>
</thead>
</table>
【问题讨论】:
-
这个代码在你调用它时立即运行,如果它在 head 文档的其余部分还没有准备好,所以它找不到任何元素
-
你能把它放在小提琴里吗?
-
你能发布你的 HTML 吗?
-
已将其添加到 jsfiddle(有问题)
标签: javascript jquery closures