我在一个内部站点上工作,并且无法对 Google 的 API 进行外部调用以使用他们的 setOnLoadCallback() 函数,并且似乎找不到任何可以与本地调用的 JQuery 一起使用的纯 JQuery 替代方案。作为参考,这是我尝试实现的代码,但原始开发人员使用 Google API 编写了它:
<script type="text/javascript">
google.load("jquery", "1.3.2");
google.load("jqueryui", "1.7.2");
google.setOnLoadCallback(function() {
var timeout = null;
var initialMargin = parseInt($("#siteMenuBar").css("margin-top"));
$("#siteMenuBar").hover(
function() {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
$(this).animate({ marginTop: 0 }, 'fast');
},
function() {
var menuBar = $(this);
timeout = setTimeout(function() {
timeout = null;
menuBar.animate({ marginTop: initialMargin }, 'slow');
}, 1000);
}
);
});
</script>
任何建议/想法表示赞赏。