我使用jquery插件來顯示滑塊網格,當我使用jquery 1.6時它工作正常,當我更改爲jquery 2.4。 1它顯示這樣的錯誤:未捕獲的錯誤:語法錯誤,無法識別的表達式:.tj_row_1,.tj_row_2,.tj_row_3,在Function.Sizzle.error
未被捕獲的錯誤:語法錯誤,不能識別的表達式:.tj_row_1,.tj_row_2,.tj_row_3,在Function.Sizzle.error
搜索後,我發現造成這部分代碼的錯誤:
pagination : function($wrapper, dir, opts) {
var config = $wrapper.data('config');
if((dir === 1 && config.currentRow + opts.rows > config.totalRows) ||
(dir === -1 && config.currentRow - 1 <= 0)
) {
$wrapper.data('anim', false);
return false;
}
var movingRows = '';
for(var i = 0; i <= opts.rows; ++i) {
(dir === 1)
? movingRows += ".tj_row_" + (config.currentRow + i) + ","
: movingRows += ".tj_row_" + (config.currentRow + (i - 1)) + ",";
}
var seq_t = opts.type.factor,
$elements;
var dircond = 1;
if(opts.type.reverse) dircond = -1;
if(dir === dircond) {
$elements = $wrapper.children(movingRows);
}else {
$elements = $wrapper.children(movingRows).reverse();
}
var total_elems = $elements.length,
cnt = 0;
$elements.each(function(i) {
var $el = $(this),
row = $el.attr("class"),
animParam = {},
currentRow = config.currentRow;
setTimeout(function() {
// if first row fade out
// if last row fade in
// for all the rows move them up/down
if(dir === 1) {
if( row === "tj_row_" + (currentRow)) {
animParam.opacity = 0;
}
else if(row === "tj_row_" + (currentRow + opts.rows)) {
animParam.opacity = 1;
}
}
else {
if( row === "tj_row_" + (currentRow - 1)) {
animParam.opacity = 1;
}
else if(row === "tj_row_" + (currentRow + opts.rows - 1)) {
animParam.opacity = 0;
}
}
$el.show();
(dir === 1)
? animParam.top = $el.position().top - $el.height() + 'px'
: animParam.top = $el.position().top + $el.height() + 'px'
$el.stop().animate(animParam, opts.type.speed, opts.type.easing, function() {
if(parseInt(animParam.top) < 0 || parseInt(animParam.top) > $el.height() * (opts.rows - 1))
$el.hide();
++cnt;
if(cnt === total_elems) {
$wrapper.data('anim', false);
}
});
}, seq_t + i * seq_t);
});
(dir === 1) ? config.currentRow += 1 : config.currentRow -= 1;
$wrapper.data('config', config);
}
錯誤已更改爲:遺漏的類型錯誤在HTMLSpanElement上的jquery.gridnav.js:345) 。(jquery.gridnav.js:710) at HTMLSpanElement.dispatch(jquery-2.1.4.js:4435) at HTMLSpanElement.elemData.handle(jquery-2.1.4.js:4121) –
啊是的,我的錯誤。我以爲'opts.rows'是一個數組。我爲你更新了答案 –