Is it possible to have the scrollbar at the bottom by default?
P粉795311321
P粉795311321 2023-09-15 20:08:44
0
1
756

I select the option label with scrollbar to view the contents of the dropdown list. I want that when we click to select an item, the scrollbar should be at the bottom.

jquery code

$('document').ready(function(){
    $('#textin1').click(function() {
        var pos = $('#textin1').offset();
        pos.top += $('#textin1').width();
        
        $('#dropdown').fadeIn(100);
       $('#dropdown').scrollTop($('#dropdown').find('li:contains("'+$('#textin1').val()+'")').position().top);
        return false;
    });

    $('#dropdown li').click(function() {
        $('#textin1').val($(this).text());
        $('#dropdown li').removeClass('selected');
        $(this).addClass('selected');
        $(this).parent().fadeOut(100);
    });
});

P粉795311321
P粉795311321

reply all(1)
P粉287726308

Try this maybe it will work for you

const scrolling = document.getElementById("scroll");

const config = { childList: true };

const callback = function (mutationsList, observer) {
  for (let mutation of mutationsList) {
    if (mutation.type === "childList") {
      window.scrollTo(0, document.body.scrollHeight);
    }
  }
};

const observer = new MutationObserver(callback);
observer.observe(scrolling, config);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template