我有這段代碼,但它似乎有錯誤。該錯誤說Uncaught typeError對象#沒有方法'HasScrollBar'是否有代碼有問題?該HasScrollbar方法在功能上的頂部聲明,但它似乎不能找到它,請參閱下面的代碼jquery的錯誤
$.fn.HasScrollBar = function() {
//note: clientHeight= height of holder
//scrollHeight= we have content till this height
var _elm = $(this)[0];
var _hasScrollBar = false;
if ((_elm.clientHeight < _elm.scrollHeight) ||
(_elm.clientWidth < _elm.scrollWidth)) {
_hasScrollBar = true;
}
return _hasScrollBar;
}
function ab() {
var a = $('td');
$.each(a, function (i, data) {
var check = data.HasScrollBar();
if (check == true) {
data.addClass('Overflow');
data.attr('title', data.text());
}
data.attr('title', data.text());
debugger;
});
};
$('.Test').on('click', function() {
ab();
});
'has scrollbar'!='HasScrollBar' – Stefan
你是什麼意思? – bRaNdOn
這個錯誤不太可能說「沒有方法」有滾動條「」,除非你用'$('foo')['有滾動條']'調用它。請務必複製粘貼錯誤消息*,否則人們會被誤解。 – JJJ