javascript - ScrollTop on overflow:hidden list items -


I have a simple list, I want to reset the top position every time I click the click button. Although I do not seem to be able to get my scrolls to work and I do not understand why.

This is a

HTML:

  & lt; Div class = "list-controller" & gt; & Lt; Div class = "arrow-up" & gt; & Lt; / Div & gt; & Lt; ul id = "list" & gt; & Lt; Li id = "first" & gt; Item 1 & lt; / li & gt; & Lt; Li & gt; Item 2 & lt; / li & gt; & Lt; Li & gt; Item 3 & lt; / li & gt; & Lt; Li & gt; Item 4 & lt; / li & gt; & Lt; Li & gt; Item 5 & lt; / li & gt; & Lt; Li & gt; Item 6 & lt; / li & gt; & Lt; Li & gt; Item 7 & lt; / li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; Button class = "click" & gt; Click & lt; / Button & gt;   

CSS:

  .listContainer {height: 100px; Width: 100px; Background: Gray; Overflow-y: scroll; } Ul # list {background: gray; Overflow-y: scroll; } Li {background: white; Art color; }   

jQuery:

  $ ('listcontainer'). ScrollTop () + $ ('li # first'). Event (). Top;    

Are you sure you use $ ('listContainer') Do not like and $ ('.listcontainer') do not like ? Besides, why bother up? .scrollTop (0) Do not you have to go to the top?

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -