Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                 <h1>Jquery scroll to content in scrollable div</h1>
        <div class="scrollable">
                <li data-index="1" class="active">Apple</li>
                <li data-index="2">Orange</li>
                <li data-index="3">Grapes</li>
                <li data-index="4">Strawberry</li>
                <li data-index="5">Cherry</li>
                <li data-index="6">Blueberry</li>
                <li data-index="7">Mango</li>
                <li data-index="8">Plum</li>
                <li data-index="9">Pineapple</li>
                <li data-index="10">Papaya</li>
                <li data-index="11">Apple</li>
                <li data-index="12">Orange</li>
                <li data-index="13">Grapes</li>
                <li data-index="14">Strawberry</li>
                <li data-index="15">Cherry</li>
                <li data-index="16">Blueberry</li>
                <li data-index="17">Mango</li>
                <li data-index="18">Plum</li>
                <li data-index="19">Pineapple</li>
                <li data-index="20">Papaya</li>
                <li data-index="21">Apple</li>
                <li data-index="22">Orange</li>
                <li data-index="23">Grapes</li>
                <li data-index="24">Strawberry</li>
                <li data-index="25">Cherry</li>
                <li data-index="26">Blueberry</li>
                <li data-index="27">Mango</li>
                <li data-index="28">Plum</li>
                <li data-index="29">Pineapple</li>
                <li data-index="30">Papaya</li>
                <li data-index="31">Apple</li>
                <li data-index="32">Orange</li>
                <li data-index="33">Grapes</li>
                <li data-index="34">Strawberry</li>
                <li data-index="35">Cherry</li>
                <li data-index="36">Blueberry</li>
                <li data-index="37">Mango</li>
                <li data-index="38">Plum</li>
                <li data-index="39">Pineapple</li>
                <li data-index="40">Papaya</li>

        <div class="pagination">
                    <li data-index="1" class="active">1</li>
                    <li data-index="2">2</li>
                    <li data-index="3">3</li>
                    <li data-index="4">4</li>
                    <li data-index="5">5</li>
                    <li data-index="6">6</li>
                    <li data-index="7">7</li>
                    <li data-index="8">8</li>
                    <li data-index="9">9</li>
                    <li data-index="10">10</li>
                    <li data-index="11">11</li>
                    <li data-index="12">12</li>
                    <li data-index="13">13</li>
                    <li data-index="14">14</li>
                    <li data-index="15">15</li>
                    <li data-index="16">16</li>
                    <li data-index="17">17</li>
                    <li data-index="18">18</li>
                    <li data-index="19">19</li>
                    <li data-index="20">20</li>
                    <li data-index="21">21</li>
                    <li data-index="22">22</li>
                    <li data-index="23">23</li>
                    <li data-index="24">24</li>
                    <li data-index="25">25</li>
                    <li data-index="26">26</li>
                    <li data-index="27">27</li>
                    <li data-index="28">28</li>
                    <li data-index="29">29</li>
                    <li data-index="30">30</li>
                    <li data-index="31">31</li>
                    <li data-index="32">32</li>
                    <li data-index="33">33</li>
                    <li data-index="34">34</li>
                    <li data-index="35">35</li>
                    <li data-index="36">36</li>
                    <li data-index="37">37</li>
                    <li data-index="38">38</li>
                    <li data-index="39">39</li>
                    <li data-index="40">40</li>
            <div class="icons">
                <i class="fa fa-chevron-left move up" aria-hidden="true"></i>
                <i class="fa fa-chevron-right move down" aria-hidden="true"></i>


                h1 {
    text-align: center;
    text-transform: capitalize;

.scrollable {
    width: 600px;
    margin: 40px auto;
    height: 60vh;
    overflow: auto;
    border: 5px solid #dedcdc;
    padding: 10px 20px;

.pagination {
    width: 600px;
    margin: 40px auto;
    border: 5px solid #dedcdc;
    padding: 10px 20px;

ul {
    margin: 0;
    list-style: none;
    padding: 0;

.scrollable li {
    padding: 10px 1px;
    border-bottom: 1px solid #eceaea;

.pagination ul {
    display: flex;
    overflow: auto;

.pagination ul li {
    margin-right: 10px;
    border: 1px solid #7fd6e4;
    border-radius: 5px;
    padding: 2px 10px;
    cursor: pointer;

.pagination ul li:hover, {
    background-color: #7fd6e4;
    color: #000000;

.icons {
    text-align: center;
    margin: 15px 0;
    font-size: 20px;
    color: #3cd8f1;

.icons i {
    cursor: pointer;



                  $(function() {
    // scroll to fruits on click of navigation
    $(".pagination li").click(function() {
        // initialize
        let activeClass = "active";
        let index = $(this).data("index");
        let element = $(
            '.scrollable li[data-index="' + index + '"]'
        let parentDiv = $(".scrollable");

        // check if already active
        if ($(this).hasClass(activeClass)) {

        // add and remove classes

        // lets scroll
                    parentDiv.scrollTop() +
                    element.position().top -

    // next/previous navigation

    $(".move").click(function() {
        let direction = $(this).hasClass("up");
        let element = $(".pagination").find(".active");
        let activeIndex ="index");
        if (direction && activeIndex == 1) {
        if (direction) {
        } else {