How do I make my Next and Previous buttons move this carousel? I already got it to slide transition automatically, but can’t get manual navigation

I am trying to make a carousel for our company LMS homepage. I want it to automatically transition through each carousel item (the banner images) as well as have it so people can click buttons to navigate back or forward through the carousel items without breaking the automatic timer. I have the automatic slide transitioning working and I have the buttons built for manually navigating. I just can’t figure out how to make the buttons work.
I am not too experienced with Javascript and I am guessing that is what I need to get this all working. So, if anyone could help me figure this out, I’d be eternally grateful!

My entire code is below for reference:

<!DOCTYPE html>
<html>
<head>
    <link tabindex="11" rel="preconnect" href="https://fonts.googleapis.com">
    <link tabindex="11" rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link tabindex="11" href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <style>
    * {box-sizing: border-box}
    body {
    font-family: "Open Sans"; 
    margin:0; 
    white-space: nowrap;

    }


    * {
    margin: 0;
    padding: 0;
    }

    .carousel_items {
    display: flex;
    overflow: hidden;
    }


    .carousel_item {
    position: relative;
    min-width: 100%;
    max-width: 100%;
    height: 200px;
    transition: all 0.5s linear;
    background-repeat: no-repeat;
    background-size: cover;


    }
    .carousel_text {
    color: #f2f2f2;
    font-size: 4vh;
    padding: 8px 12px;
    position: absolute;
    bottom: 70px;
    width: 26%;
    text-align: center;
    background-color: none;
    font-family: "Open Sans";
    font-size: calc(1.5rem + 0.3vw);


    }

    .item1 {
    background-image: url("https://images.unsplash.com/photo-1707218526479-91d005196060?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");

    }
    .item2 {
    background-image: url("https://images.unsplash.com/photo-1435527173128-983b87201f4d?q=80&w=2067&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");
    }
    .item3 {
    background-image: url("https://images.unsplash.com/photo-1523655223303-4e9ef5234587?q=80&w=2074&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");
    }



    .prev, .next {
    cursor: pointer;
    position: absolute;
    top: 10%;
    width: auto;
    padding-top: 30px;
    padding-bottom: 30px;
    padding-right: 15px;
    padding-left: 15px;
    margin-top: -40px;
    color: white;
    font-weight: bold;
    font-size: calc(1.5rem + 0.3vw);
    transition: 0.6s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    }


    .next {
    right: 0;
    border-radius: 3px 0 0 3px;
    }

    .prev:hover, .next:hover {
    background-color: rgba(0,0,0,0.8);
    }


    @media only screen and (max-width: 300px) {
    .prev, .next,.text {font-size: 11px}
    }


        
</style>
</head>
<body>

    
    <div class="carousel-container">
  <div class="carousel_items">
    <div class="carousel_item item1">
      <p class="carousel_text">Featured Training</p>
    </div>
    <div class="carousel_item item2">
      <p class="carousel_text">Activity Calendar</p>
    </div>
    <div class="carousel_item item3">
      <p class="carousel_text">Technical Learning</p>
    </div>
    
  </div>
    <a class="prev" onclick="plusSlides(-1)"><i class="material-icons">chevron_left</i></a>
        <a class="next" onclick="plusSlides(1)"><i class="material-icons">chevron_right</i></a> 
        
</div>

    
    </body>
    
    
    
<script>
    const carouselItems = document.querySelectorAll(".carousel_item"); 
let i = 1;

setInterval(() => {
 Array.from(carouselItems).forEach((item,index) => {
   if(i < carouselItems.length){
    item.style.transform = `translateX(-${i*100}%)`
   }
  })

    
  if(i < carouselItems.length){
    i++;
  }
  else{
    i=0;
  }
},4000)
    
    

    </script>



</html> 

I’ve tried adding triggers to the buttons but I just am far too inexperienced with Javascript. Trying to implement other people’s javascript codes for navigation buttons was too hard to get to work as well. So, I never really got anywhere.

New contributor

Fourkings13 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

How do I make my Next and Previous buttons move this carousel? I already got it to slide transition automatically, but can’t get manual navigation

I am trying to make a carousel for our company LMS homepage. I want it to automatically transition through each carousel item (the banner images) as well as have it so people can click buttons to navigate back or forward through the carousel items without breaking the automatic timer. I have the automatic slide transitioning working and I have the buttons built for manually navigating. I just can’t figure out how to make the buttons work.
I am not too experienced with Javascript and I am guessing that is what I need to get this all working. So, if anyone could help me figure this out, I’d be eternally grateful!

My entire code is below for reference:

<!DOCTYPE html>
<html>
<head>
    <link tabindex="11" rel="preconnect" href="https://fonts.googleapis.com">
    <link tabindex="11" rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link tabindex="11" href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <style>
    * {box-sizing: border-box}
    body {
    font-family: "Open Sans"; 
    margin:0; 
    white-space: nowrap;

    }


    * {
    margin: 0;
    padding: 0;
    }

    .carousel_items {
    display: flex;
    overflow: hidden;
    }


    .carousel_item {
    position: relative;
    min-width: 100%;
    max-width: 100%;
    height: 200px;
    transition: all 0.5s linear;
    background-repeat: no-repeat;
    background-size: cover;


    }
    .carousel_text {
    color: #f2f2f2;
    font-size: 4vh;
    padding: 8px 12px;
    position: absolute;
    bottom: 70px;
    width: 26%;
    text-align: center;
    background-color: none;
    font-family: "Open Sans";
    font-size: calc(1.5rem + 0.3vw);


    }

    .item1 {
    background-image: url("https://images.unsplash.com/photo-1707218526479-91d005196060?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");

    }
    .item2 {
    background-image: url("https://images.unsplash.com/photo-1435527173128-983b87201f4d?q=80&w=2067&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");
    }
    .item3 {
    background-image: url("https://images.unsplash.com/photo-1523655223303-4e9ef5234587?q=80&w=2074&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");
    }



    .prev, .next {
    cursor: pointer;
    position: absolute;
    top: 10%;
    width: auto;
    padding-top: 30px;
    padding-bottom: 30px;
    padding-right: 15px;
    padding-left: 15px;
    margin-top: -40px;
    color: white;
    font-weight: bold;
    font-size: calc(1.5rem + 0.3vw);
    transition: 0.6s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    }


    .next {
    right: 0;
    border-radius: 3px 0 0 3px;
    }

    .prev:hover, .next:hover {
    background-color: rgba(0,0,0,0.8);
    }


    @media only screen and (max-width: 300px) {
    .prev, .next,.text {font-size: 11px}
    }


        
</style>
</head>
<body>

    
    <div class="carousel-container">
  <div class="carousel_items">
    <div class="carousel_item item1">
      <p class="carousel_text">Featured Training</p>
    </div>
    <div class="carousel_item item2">
      <p class="carousel_text">Activity Calendar</p>
    </div>
    <div class="carousel_item item3">
      <p class="carousel_text">Technical Learning</p>
    </div>
    
  </div>
    <a class="prev" onclick="plusSlides(-1)"><i class="material-icons">chevron_left</i></a>
        <a class="next" onclick="plusSlides(1)"><i class="material-icons">chevron_right</i></a> 
        
</div>

    
    </body>
    
    
    
<script>
    const carouselItems = document.querySelectorAll(".carousel_item"); 
let i = 1;

setInterval(() => {
 Array.from(carouselItems).forEach((item,index) => {
   if(i < carouselItems.length){
    item.style.transform = `translateX(-${i*100}%)`
   }
  })

    
  if(i < carouselItems.length){
    i++;
  }
  else{
    i=0;
  }
},4000)
    
    

    </script>



</html> 

I’ve tried adding triggers to the buttons but I just am far too inexperienced with Javascript. Trying to implement other people’s javascript codes for navigation buttons was too hard to get to work as well. So, I never really got anywhere.

New contributor

Fourkings13 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật