猿问

js控制移动到底部触发

$(window).scroll(function () {

  var scrollTop = $(this).scrollTop()

  var windowHeight = $(this).height()

  var scrollHeight = $(document).height()

  console.log('-----------------------')

  if((scrollTop+windowHeight)>scrollHeight){

    console.log('bottom')

  }


  console.log(`scrollTop: ${scrollTop}`)

  console.log(`windowHeight: ${windowHeight}`)

  console.log(`scrollHeight: ${scrollHeight}`)


})

想要移动底部触发事件,是我哪里写的不对吗,一直不能正确获取

慕妹3242003
浏览 488回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答