scrollIntoView Scrolls just too far

前端 未结 21 2039
盖世英雄少女心
盖世英雄少女心 2020-12-07 10:08

I have a page where a scroll bar containing table rows with divs in them is dynamically generated from the database. Each table row acts like a link, sort of like you\'d see

21条回答
  •  春和景丽
    2020-12-07 10:46

    For an element in a table row, use JQuery to get the row above the one you want, and simply scroll to that row instead.

    Suppose I have multiple rows in a table, some of which should be reviewed by and admin. Each row requiring review has both and up and a down arrow to take you to the previous or next item for review.

    Here's a complete example that should just run if you make a new HTML document in notepad and save it. There's extra code to detect the top and bottom of our items for review so we don't throw any errors.

    
    
        Scrolling Into View
        
        
    
    
    
    Review Data
    Row 1 (OK)
    Row 2 (OK)
    UP DN Row 3 (REVIEW)
    Row 4 (OK)
    UP DN Row 5 (REVIEW)
    Row 6 (OK)
    Row 7 (OK)
    UP DN Row 8 (REVIEW)
    Row 9 (OK)
    Row 10 (OK)

提交回复
热议问题