【发布时间】:2014-07-04 15:51:51
【问题描述】:
我正在尝试在Drupal 7 中使用jquery。我已将以下代码放入模块js 文件中,并使用drupal_add_js 加载它。起初,我的模块js 文件中发生了同样的错误,在谷歌搜索后我发现我应该将代码包装在一个函数中。但修复后,错误发生在jquery.js?v=1.4.4。这是我的代码:
(function($) {
$(document).mouseup(function (e)
{
var container = $("div#top-bar-menu-wrapper");
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
}
});
}(jQuery));
以及错误截图:
【问题讨论】: