Subtract from an integer using jquery

后端 未结 3 1351
北恋
北恋 2021-01-27 06:20

I want to scroll to a div each time user presses j key. Here is the code for it.

$(function() {
    function scroll(direction) {

        var s         


        
3条回答
  •  [愿得一人]
    2021-01-27 07:15

    $(scroll).offset().top-50 is prefectly valid, as .top will return an integer value. Therefore the issue is not with this portion of your code.

    I suspect the issue is to do with the scroll variable you have within the scroll function. I always keep away from naming my variables the same as my function names when within the same scope.

提交回复
热议问题