mardi 18 mai 2021

Sort an ordered list by rating (javascript)

Long story short, my website contains a list of hotels that have few infos. I wanna sort the ordered list of hotels by one of those infos e.g. by rating. I did some research and still couldn't find the right js algorithm for it to make it work.

<ol>
  <li class="item">
    <div class="hotel-container">
      <div class="hotel-info">
        <h1>A</h1>
        <div class="rating"><span>3.8</span></div>
      </div>
    </div>
  </li>
  <li class="item">
    <div class="hotel-container">
      <div class="hotel-info">
        <h1>B</h1>
        <div class="rating"><span>4.5</span></div>
      </div>
    </div>
  </li>
  <li class="item">
    <div class="hotel-container">
      <div class="hotel-info">
        <h1>C</h1>
        <div class="rating"><span>2.2</span></div>
      </div>
    </div>
  </li>
</ol>






Aucun commentaire:

Enregistrer un commentaire