我已經編寫了代碼來檢查textarea向下滾動。 Mcode在FF4中工作正常,但在Chrome中沒有工作。`> =`條件不適用於鉻
var psconsole = $('#tos');
//psconsole.scrollTop(psconsole[0].scrollHeight - psconsole.height());
psconsole.scroll(function(){
var acutalHight = psconsole[0].scrollHeight - psconsole.height();
var scrolHight = psconsole[0].scrollTop ;
console.log("scrolHight:" + scrolHight + "<<<<>>>>>"+ "acutalHight:" +acutalHight);
if(scrolHight+10 >= acutalHight){
$("#btnSignup").attr("disabled", false);
}else{
$("#btnSignup").attr("disabled", true);
}
});
如果條件>=
不使用Chrome
而滾動的scrolHight價值和acutalHeight值,如下
scrolHight:2627<<<<>>>>>acutalHight:2696
scrolHight:2639<<<<>>>>>acutalHight:2696
scrolHight:2651<<<<>>>>>acutalHight:2696
scrolHight:2675<<<<>>>>>acutalHight:2696
scrolHight:2687<<<<>>>>>acutalHight:2696
scrolHight:2696<<<<>>>>>acutalHight:2696
鉻我得到滾動值如下
doSignUp:179scrolHight:1862<<<<>>>>>acutalHight:2686
doSignUp:179scrolHight:2128<<<<>>>>>acutalHight:2686
doSignUp:179scrolHight:2394<<<<>>>>>acutalHight:2686
doSignUp:179scrolHight:2660<<<<>>>>>acutalHight:2686
doSignUp:179scrolHight:2670<<<<>>>>>acutalHight:2686
doSignUp:179scrolHight:2682<<<<>>>>>acutalHight:2686
我認爲問題是鉻不計算textarea heig直到最後textarea有一些拖動圖標在4px結束....鉻不計算,但FF4做。而且它不是在IE9工作太
您是否嘗試過使用鉻檢查器進行調試?確保沒有錯誤發生? (我也假設它不是變量名稱,因爲(雖然拼寫錯誤)它們是一致的。) – 2011-06-05 18:16:00
請您在這種情況之前告訴我scrolHight和acutalHight的值,因爲它可能很好,它們不是數字即包含「px」或其他東西,甚至包含自動,%或類似的東西。 – Niklas 2011-06-05 18:18:29