Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Javier Gandia
seal-mask
.a{fill-rule:evenodd;}techdegree
Javier Gandia
Full Stack JavaScript Techdegree Student 9,153 Points

Alright, TreeHouse Community. I need your help. Pagination Filter Project.

I want to complete this project with the search on it.. I cant seem to get it right though.. I'm missing a few details for it to work perfect.. problems:

  1. it repeats "No student" text 65 times.
  2. add the style already used in the html on that "No student" text. (this one might be simple enough for me to figure out. Just need a little direction)
  3. make it so the search isn't so broad. (ex. if u search "a" every name the has the letter "a" appears.) I want to make it so it searched the first letters of the name. and show those names only.
  4. If the search does indeed contain more than 10 names, I want no more than 10 names to load per page. I've made a function to only load 10 names per page, but can't figure out how to apply it to this.

That's it I believe.. If you see any other improvements, please tell me. I won't submit this project till I get some input.. Thank you..

Here's the entire JS code:

//variable with the student-items in the student-list class value..
const $studentsList = $("ul.student-list li.student-item");


const paginationFunction = ()=> {
    //eventlistener
    $(".pagination ul li a").on("click", function(){
    //sets index of the li u clicking.. ex. click on the 3rd li returns 2.
    let index = $(".pagination ul li a").index(this);
    //remove "active" class so its not highlighted
    $("a").removeClass("active");
    //hide all studentsList in page. then slice the arrays.. and multiple by 10 to get 10 items at a time.
    //ex. 3rd item is index 2, (10 * index(which is 2),10 * (index + 1).
    $($studentsList).hide().slice(10 * index,10 * (index + 1)).show();
    //add class back into that clicked anchor tag
    $(this).addClass('active');
});
};

//event handler to load only first 10 items when page loads.
$(window).on("load", function(e) {
    $($studentsList).hide().slice(0,10).show();
    //start paginationFunction on load.
    paginationFunction();
});


$("#searchButton").on("click", function() {
    $($studentsList).show();
    let $filteredUserInput = $("#userInput").val().toUpperCase();
        for(let i = 0; i < $studentsList.length; i++){
            let $studentName = $("h3")[i].innerHTML.toUpperCase();
                if($studentName.toUpperCase().indexOf($filteredUserInput) < 0 || $filteredUserInput.length == 0 || $filteredUserInput == " ") {
                    $(".pagination").remove();
                    $($studentsList[i]).hide();
                    $(".student-list").append("<p>No student with that name.</p>");
                } else if ($studentName.toUpperCase().indexOf($filteredUserInput) > 0){
                    $(studentsList[i]).show();

                }
            }
});

and here's the entire html..

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Students</title>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/design.css">
  </head>
  <body>
    <div class="page">
      <div class="page-header cf">
        <h2><a href="index.html" style="color: inherit">Students</a></h2>

        <!-- student search HTML to add dynamically -->
        <div class="student-search">
          <input id="userInput" placeholder="Search for students...">
          <button id="searchButton">Search</button>
        </div>
        <!-- end search -->

      </div>
      <ul class="student-list">
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/67.jpg">
                <h3>iboya vat</h3>
                <span class="email">iboya.vat@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/15/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/75.jpg">
                <h3>aapo niskanen</h3>
                <span class="email">aapo.niskanen@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/15/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/34.jpg">
                <h3>phillip cox</h3>
                <span class="email">phillip.cox@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 09/11/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/38.jpg">
                <h3>zilda moreira</h3>
                <span class="email">zilda.moreira@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/15/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/23.jpg">
                <h3>lilou le gall</h3>
                <span class="email">lilou.le gall@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/16/13</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/94.jpg">
                <h3>lucy hall</h3>
                <span class="email">lucy.hall@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 09/11/16</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/24.jpg">
                <h3>mark colin</h3>
                <span class="email">mark.colin@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 01/14/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/14.jpg">
                <h3>sara alves</h3>
                <span class="email">sara.alves@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/19/16</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/49.jpg">
                <h3>ramon macrae</h3>
                <span class="email">ramon.macrae@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/13/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/15.jpg">
                <h3>connor taylor</h3>
                <span class="email">connor.taylor@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/18/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/11.jpg">
                <h3>aymeric morel</h3>
                <span class="email">aymeric.morel@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/13/13</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/49.jpg">
                <h3>lorenz otto</h3>
                <span class="email">lorenz.otto@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/11/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/29.jpg">
                <h3>karl williamson</h3>
                <span class="email">karl.williamson@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 01/12/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/34.jpg">
                <h3>ouassim heering</h3>
                <span class="email">ouassim.heering@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 01/18/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/91.jpg">
                <h3>roberto molina</h3>
                <span class="email">roberto.molina@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/13/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/28.jpg">
                <h3>jordan hubert</h3>
                <span class="email">jordan.hubert@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/13/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/29.jpg">
                <h3>melvin baker</h3>
                <span class="email">melvin.baker@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 09/18/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/26.jpg">
                <h3>everett gordon</h3>
                <span class="email">everett.gordon@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/17/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/82.jpg">
                <h3>aiden ma</h3>
                <span class="email">aiden.ma@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/18/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/62.jpg">
                <h3>florent gerard</h3>
                <span class="email">florent.gerard@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 02/12/13</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/96.jpg">
                <h3>amber chen</h3>
                <span class="email">amber.chen@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/12/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/9.jpg">
                <h3>alexandra davies</h3>
                <span class="email">alexandra.davies@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/11/13</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/57.jpg">
                <h3>sergio cole</h3>
                <span class="email">sergio.cole@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 02/17/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/98.jpg">
                <h3>edgar dixon</h3>
                <span class="email">edgar.dixon@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/17/11</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/94.jpg">
                <h3>kirk myers</h3>
                <span class="email">kirk.myers@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 09/17/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/28.jpg">
                <h3>ani hesseling</h3>
                <span class="email">ani.hesseling@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 08/14/16</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/24.jpg">
                <h3>victoire bonnet</h3>
                <span class="email">victoire.bonnet@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/13/16</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/44.jpg">
                <h3>marcos morales</h3>
                <span class="email">marcos.morales@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 01/12/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/75.jpg">
                <h3>nils neumann</h3>
                <span class="email">nils.neumann@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 03/11/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/67.jpg">
                <h3>iboya vat</h3>
                <span class="email">iboya.vat@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/15/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/75.jpg">
                <h3>aapo niskanen</h3>
                <span class="email">aapo.niskanen@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/15/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/34.jpg">
                <h3>phillip cox</h3>
                <span class="email">phillip.cox@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 09/11/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/38.jpg">
                <h3>zilda moreira</h3>
                <span class="email">zilda.moreira@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/15/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/23.jpg">
                <h3>lilou le gall</h3>
                <span class="email">lilou.le gall@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/16/13</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/94.jpg">
                <h3>lucy hall</h3>
                <span class="email">lucy.hall@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 09/11/16</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/24.jpg">
                <h3>mark colin</h3>
                <span class="email">mark.colin@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 01/14/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/14.jpg">
                <h3>sara alves</h3>
                <span class="email">sara.alves@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/19/16</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/49.jpg">
                <h3>ramon macrae</h3>
                <span class="email">ramon.macrae@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/13/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/15.jpg">
                <h3>connor taylor</h3>
                <span class="email">connor.taylor@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/18/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/86.jpg">
                <h3>emily harrison</h3>
                <span class="email">emily.harrison@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/18/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/41.jpg">
                <h3>matthew fortin</h3>
                <span class="email">matthew.fortin@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 03/18/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/32.jpg">
                <h3>charlotte steward</h3>
                <span class="email">charlotte.steward@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 02/18/11</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/3.jpg">
                <h3>marceau rodriguez</h3>
                <span class="email">marceau.rodriguez@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/13/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/91.jpg">
                <h3>hudson anderson</h3>
                <span class="email">hudson.anderson@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 09/12/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/33.jpg">
                <h3>warren phillips</h3>
                <span class="email">warren.phillips@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 01/11/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/41.jpg">
                <h3>leo niva</h3>
                <span class="email">leo.niva@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 09/14/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/3.jpg">
                <h3>hani prevoo</h3>
                <span class="email">hani.prevoo@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 01/11/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/79.jpg">
                <h3>veronica rodriguez</h3>
                <span class="email">veronica.rodriguez@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/17/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/41.jpg">
                <h3>ginestal das neves</h3>
                <span class="email">ginestal.das neves@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/19/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/63.jpg">
                <h3>devon barnes</h3>
                <span class="email">devon.barnes@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 09/19/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/55.jpg">
                <h3>brennan pierce</h3>
                <span class="email">brennan.pierce@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/15/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/35.jpg">
                <h3>zachary singh</h3>
                <span class="email">zachary.singh@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/19/11</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/35.jpg">
                <h3>arlo harris</h3>
                <span class="email">arlo.harris@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 07/12/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/60.jpg">
                <h3>hannah ginnish</h3>
                <span class="email">hannah.ginnish@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/17/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/95.jpg">
                <h3>goos brunt</h3>
                <span class="email">goos.brunt@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 09/15/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/91.jpg">
                <h3>eduard riedel</h3>
                <span class="email">eduard.riedel@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/12/15</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/42.jpg">
                <h3>geesken jekel</h3>
                <span class="email">geesken.jekel@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 02/12/13</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/54.jpg">
                <h3>dolores ryan</h3>
                <span class="email">dolores.ryan@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/17/16</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/49.jpg">
                <h3>steven rogers</h3>
                <span class="email">steven.rogers@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 01/18/11</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/63.jpg">
                <h3>virgulino silva</h3>
                <span class="email">virgulino.silva@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 03/18/11</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/11.jpg">
                <h3>lucile bertrand</h3>
                <span class="email">lucile.bertrand@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 06/13/16</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/10.jpg">
                <h3>elsa lahti</h3>
                <span class="email">elsa.lahti@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 04/15/12</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/12.jpg">
                <h3>soline leclercq</h3>
                <span class="email">soline.leclercq@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/12/14</span>
           </div>
        </li>
        <li class="student-item cf">
            <div class="student-details">
                <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/89.jpg">
                <h3>henri kruse</h3>
                <span class="email">henri.kruse@example.com</span>
            </div>
            <div class="joined-details">
                   <span class="date">Joined 05/14/13</span>
           </div>
        </li>
      </ul>

          <!-- pagination HTML to create dynamically -->
          <div class="pagination">
            <ul>
              <li>
                <a class="active" href="#">1</a>
              </li>
               <li>
                <a href="#">2</a>
              </li>
               <li>
                <a href="#">3</a>
              </li>
               <li>
                <a href="#">4</a>
              </li>
               <li>
                <a href="#">5</a>
              </li>
              </li>
               <li>
                <a href="#">6</a>
              </li>
            </ul>
          </div>
          <!-- end pagination -->

        </div>
      </body>
    </html>
    <script
      src="http://code.jquery.com/jquery-3.2.1.min.js"
      integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
      crossorigin="anonymous"></script>
    <script src="js/main.js" charset="utf-8"></script>
  </body>
</html>
Steven Parker
Steven Parker
216,136 Points

Next time, consider sharing a link to your repo or workspace snapshot.

1 Answer

Steven Parker
Steven Parker
216,136 Points

Here's a few answers:

  • it repeats "No student" text 65 times.

Well, inside the loop, for each student you hide, you also append that message as a paragraph to the student-list element. For one thing, while inside the loop you probably want only to keep track of whether or not any students are shown. Then after the loop, you can use that information to display the message or not. But you also don't want to be adding paragraph elements to a ul (children of a ul should all be li elements). What might work better is to have that paragraph element on the page already, identified by a unique class or id, and then just hide or show it as appropriate.

  • add the style already used in the html on that "No student" text. (this one might be simple enough for me to figure out. Just need a little direction)

If the style never changes, I'd just put it in the CSS.

  • make it so the search isn't so broad. (ex. if u search "a" every name the has the letter "a" appears.) I want to make it so it searched the first letters of the name. and show those names only.

Instead of discarding only negative returns from indexOf, discard anything other than 0. Then it must match only at the beginning.

  • If the search does indeed contain more than 10 names, I want no more than 10 names to load per page. I've made a function to only load 10 names per page, but can't figure out how to apply it to this.

You might need to rethink the strategy on this one. You probably want this to work even after a search, so you can't just use the index of the studentsList to divide the groups. You might try looking at other similar forum questions for ideas.