JavaScript Scrolling buttons - with jQuery scrolling buttons with tabs,scrolling with buttons,scrolling with buttons

So I'm working on a list that you can scroll through by clicking on buttons. And it also needs to have a scrollbar visible and working too. But I don't know how to edit my code to get them both to function. I can either have the buttons working or the scrollbar, not both. Can someone help?

var itemsToShow = 3;

$('#scroll>li').each(function(i,k) {
    var ele = $(this);
    $(ele).attr('id', 'scroll' + i);

});


$('#up').bind('click', function() {
    if ($('#scroll0:hidden').length > 0)
    {
        // This means we can go up
        var boundaryTop = $('ul li:visible:first').attr('id');
        var boundaryBottom = $('ul li:visible:last').attr('id');

        if ($('ul li#'+ boundaryTop).prev().length > 0)
        {
            $('ul li#'+ boundaryTop).prev().show();
            $('ul li#'+ boundaryBottom).hide();
        }
    }
});

$('#down').bind('click', function() {
    if ($('#scroll li:last:hidden').length > 0)
    {
        // This means we can go down
        var boundaryTop = $('#scroll li:visible:first').attr('id');
        var boundaryBottom = $('#scroll li:visible:last').attr('id');

        if ($('#scroll li#'+ boundaryBottom).next().length > 0)
        {
            $('#scroll li#'+ boundaryBottom).next().show();
            $('#scroll li#'+ boundaryTop).hide();
        }
}
});
.lg {
    overflow-x:auto; 
    height:90px;
    overflow-y:auto;
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<ul class="lg">
  <li>Text</li>
  <li>Text</li>
  <li>Text</li>
  <li>Text</li>
  <li>Text</li>
  <li>Text</li>
  <li>Text</li>
  <li>Text</li>
</ul>

<div id="updown">
  <a class="btn btn-primary" id="up" target='_blank' href="#">up</a>
<a class="btn btn-primary" id="down" target='_blank' href="#">down</a>
</div>
Answer:1

Here is how you scroll to top and bottom:

https://jsfiddle.net/45cmhys8/

// Scroll to the top
$('a#up').on('click', function(){
   $('.lg').animate({ scrollTop: 0 }, 600);
})
// Scroll to the bottom
$('a#down').on('click', function(){
   $(".lg").animate({ scrollTop:$(document).height()}, 600);
})
Answer:2

You can use the scrollTop() function in jQuery to do this in a one-liner.

10 is the amount of pixels you want to jump up/down.

$('#up').click(function(){
  $('ul.lg').scrollTop($('ul.lg').scrollTop()- 10);
});

$('#down').click(function(){
  $('ul.lg').scrollTop($('ul.lg').scrollTop() + 10);
});
Answer:3

Following are returned Json data from server: $scope.cities = response.data; is: 0: {id: 1, name: "Malaysia",…} city: [{id: 1, country_id: 1, city: "Kuala Lumpur"}, {id: 2, country_id: 1, city:...

Following are returned Json data from server: $scope.cities = response.data; is: 0: {id: 1, name: "Malaysia",…} city: [{id: 1, country_id: 1, city: "Kuala Lumpur"}, {id: 2, country_id: 1, city:...

  1. angularjs dropdown multiselect
  2. angularjs dropdown menu
  3. angularjs dropdown list
  4. angularjs dropdown with search
  5. angularjs dropdown change event
  6. angularjs dropdown validation example
  7. angularjs dropdown ng-repeat
  8. angularjs dropdown with text input
  9. angularjs dropdown button
  10. angularjs dropdown multiselect example
  11. angularjs dropdown selected value
  12. angularjs dropdown default selected value
  13. angularjs dropdown required validation
  14. angularjs dropdown component
  15. angularjs dropdown selected value example
  16. angularjs dropdown list from database
  17. angularjs dropdown filter
  18. angularjs dropdown selected
  19. angularjs dropdown binding
  20. angularjs dropdown default value

I am using a dropdown inside my grid. And I intend to change the value of other column based on the changed value of dropdown column. MY code looks like below dataEvents: [ { type: 'change', ...

I am using a dropdown inside my grid. And I intend to change the value of other column based on the changed value of dropdown column. MY code looks like below dataEvents: [ { type: 'change', ...

  1. jqgrid documentation
  2. jqgrid demo
  3. jqgrid events
  4. jqgrid colmodel
  5. jqgrid formatter
  6. jqgrid options
  7. jqgrid export to excel
  8. jqgrid editoptions
  9. jqgrid setgridparam
  10. jqgrid reloadgrid
  11. jqgrid getgridparam
  12. jqgrid loadcomplete
  13. jqgrid multiselect
  14. jqgrid get row data
  15. jqgrid setcell
  16. jqgrid download
  17. jqgrid bootstrap
  18. jqgrid width
  19. jqgrid pager
  20. jqgrid hide column

I'm hitting a wall with an issue and it's been probably more hours than I care to admit tracking this thing down. Specifically what I have is a jQuery AJAX call that posts some data to a .cfc I ...

I'm hitting a wall with an issue and it's been probably more hours than I care to admit tracking this thing down. Specifically what I have is a jQuery AJAX call that posts some data to a .cfc I ...

In iOS 9 beta, a bug (https://openradar.appspot.com/22186109) was introduced that meant that setting window.location.hash to some new value was not being updated until "some time" later. The exact ...

In iOS 9 beta, a bug (https://openradar.appspot.com/22186109) was introduced that meant that setting window.location.hash to some new value was not being updated until "some time" later. The exact ...

  1. window.location issue
  2. window.location safari issue
  3. window.location security issue
  4. window.location.href security issue
  5. window.location.href ie issue
  6. window.location.href fortify issue
  7. firefox window.location.reload issue