I have written code to check the textarea scroll down. Mcode working fine in FF4 but not in 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);
}
});
if condition >=
not working in Chrome
while scrolled the scrolHight value and acutalHeight value as below
scrolHight:2627<<<<>>>&开发者_开发技巧gt;>acutalHight:2696
scrolHight:2639<<<<>>>>>acutalHight:2696
scrolHight:2651<<<<>>>>>acutalHight:2696
scrolHight:2675<<<<>>>>>acutalHight:2696
scrolHight:2687<<<<>>>>>acutalHight:2696
scrolHight:2696<<<<>>>>>acutalHight:2696
in chrome I am getting scroll value as below
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
I think problem is chrome not calculating the textarea height upto the end textarea has some drag icon in end for 4px.... chrome not calculate those but FF4 did. And its not working in IE9 too
You need to use .prop()
instead of .attr()
or, if you have an old jQuery version not supporting .prop()
, use .removeAttr('disabled')
to re-enable the button..
Oh, and you have typos in your var names - they should be scrollHeight
and actualHeight
.
The logic comparision >=
most certainly does work in Chrome.
In the given example, scrolHight
is less than acutalHight
when evaluated in Chrome. Without further code nor details of where and how these variables are being set it is not possible to say why this is happening.
check to see if there are any floating point errors. Or check if the indeed can be compared at all... i.e if they are defined and is number
精彩评论