I'm working with two different html files, the index that works as a template where I load other html files such as login panel, shopping cart and, the display(where products are shown) i'm using jQuery the ready method specifically, and it works fine till I try to add a slider with js which works perfectly too when I load the display file directly, the thing is the slider is applied to the display file but when I load it with jQuery it just loads it without any of its functionalities working, i'm trying to be as clear as possibly, i'll share a piece of code, I hope you guys have an idea of what's going on.
jQuery:
function loadDisplay(){
  $(document).ready(function(){
    $("div.body-wrapper").load("display.php")
  });
}
HTML:
  <body onload="loadDisplay()">
    <div class="container">
      <div class="body-wrapper"></div>
JavaScript:
var slideIndex = 0;
function slider(){
    let i;
    let x = document.getElementsByName("bloc-one");
    for (i = 0; i < x.length; i++) {
      x[i].style.display = "none";
    }
    slideIndex++;
    if (slideIndex > x.length) {slideIndex = 1}
    x[slideIndex -1].style.display = "block";
    setTimeout(slider,3000);
  }
In conclusion the methods and functions work fine till the file is loaded in the index file which is where it stops working.