我有一個問題,我想建立一個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