zoukankan      html  css  js  c++  java
  • jQuery使用scrollTop获取div标签的滚动条已滚动高度(jQuery版本1.6+时,用prop()方法代替attr()方法)

    $("#content").append('<div>' + data.msg + '</div>'+.'<br>');
    $('#content').attr({ scrollTop: $('#content').attr('scrollHeight') });

    //jQuery版本1.6+时,用prop()方法代替attr()方法:【重点,否则获取不到】
    $('#content').prop({ scrollTop: $('#content').prop('scrollHeight') });
     
     
    例子:
    //加上动画效果
    $('#content').animate({ scrollTop: $('#content').attr('scrollHeight') }, 1000);
    //1.6+
    $('#content').animate({ scrollTop: $('#content').prop('scrollHeight') }, 1000);
     
  • 相关阅读:
    第十一周作业
    第十周作业
    第九周作业
    第八周作业
    第九周
    第八周
    第七周
    第六周
    第五周
    实验报告二
  • 原文地址:https://www.cnblogs.com/huangjianwu/p/4536369.html
Copyright © 2011-2022 走看看