javascript - Scrolling inner div on key down and up -
I have created an autocomplete container that shows the first four results and the other is hidden and the internal device The element that can be seen while scrolling is the element which holds all the results.
I have implemented the key when pressing up and down keys to easily navigate the results of navigating users, but with the result the internal div is not scrolling.
How can you scroll the element in which In the example, just press any key inside the input box and use your arrow to move down, you will see that div is not scrolling You can update your script to find the relative position of the selected element and scroll it out: overflow-y: hidden and not the window?
$ ("some input"). ("Keyp", function (a) {$ ("cover"). Show (); if (e.j. == 40) {$ ('. Element: no (last child) .element-hover'). RemoveClass ('element -hover') .next () addClass ('element-hover');} Else if (e.which == 38) {$ ('element: not (: first-child) .element-hover AddClass ('element-hover');} // scroll to element: $ (". Set top (".wrapper_div"). Scrolltop ($ ('. Element-hover: first') .offet () top-$ (".rapper.inner_div"). Height ()); // Then selected Scale from element to element Set the height of Ing}};
Comments
Post a Comment