我有一个问题,我想建立一个Ajax的一页,但我有2个不同的JS文件,因为当我有我的代码在1文件它不工作。jQuery麻烦与AJAX
我怎么能结合这些JS,它并没有在一个的.js文件的麻烦
(function($) {
$.fn.visible = function(partial) {
var $t = $(this),
$w = $(window),
viewTop = $w.scrollTop(),
viewBottom = viewTop + $w.height(),
_top = $t.offset().top,
_bottom = _top + $t.height(),
compareTop = partial === true ? _bottom : _top,
compareBottom = partial === true ? _top : _bottom;
return ((compareBottom <= viewBottom) && (compareTop >= viewTop));
};
})(jQuery);
var win = $(window);
var allMods = $(".module");
// Already visible modules
allMods.each(function(i, el) {
var el = $(el);
if (el.visible(true)) {
el.addClass("already-visible");
}
});
win.scroll(function(event) {
allMods.each(function(i, el) {
var el = $(el);
if (el.visible(true)) {
el.addClass("come-in");
}
});
});
与这一个至极的另一个页面
var win = $(window);
var allMods = $(".var");
// Already visible modules
allMods.each(function(i, el) {
var el = $(el);
if (el.visible(true)) {
el.addClass("already-visible");
}
});
win.scroll(function(event) {
allMods.each(function(i, el) {
var el = $(el);
if (el.visible(true)) {
el.addClass("come-in-var");
}
});
});
我怎么能结合它规定?谢谢!
当你将它们合并时会出现什么错误? –
这两个动画不工作:(一个第一个作品... – andre34