I am trying to implement a search box functionality to a page of images using jQuery. I don't want to use a plugin.
The code I have seems to check to see if search == data attribute instead of looking to see if the data attribute includes search
The search bar is
let images = document.getElementsByClassName('photo-link');
$('#searchbar').on('keyup', function() {
  let search = $('#searchbar').val().toLowerCase();
  $(images).each(function() {
    if (search == $(images).attr('data-alt')) {
      $(this).show();
    } else {
      $(this).fadeOut();
    }
  });
});<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section>
  <input id="searchbar" type="search" placeholder="Search" name="search">
</section>
<a class="photo-link" href="photos/01.jpg" data-alt="Hay Bales" data-fancybox="gallery" data-caption="I love hay bales. Took this snap on a drive through the countryside past some straw fields.">
  <img class="photo" src="photos/thumbnails/01.jpg" alt="Hay Bales"></a> 
    