简体   繁体   English

如何使此滑块代码适用于同一页面上的许多滑块

[英]How to make this code of slider work for many sliders on the same page

I want to use this code to show not only just one slider but many dynamic sliders .see pic 我想使用此代码不仅显示一个滑块,而且显示许多动态滑块。 在此处输入图片说明

this code just work for one slider 此代码仅适用于一个滑块

here is my code : 这是我的代码:

https://jsfiddle.net/4e13bmvu/ https://jsfiddle.net/4e13bmvu/

    <div id="le_le_slider" class="le_le_slider">
  <div class="wrapper">
    <div id="items" class="items">
      <span class="le_slide">le_slide 1</span>
      <span class="le_slide">le_slide 2</span>
      <span class="le_slide">le_slide 3</span>
      <span class="le_slide">le_slide 4</span>
      <span class="le_slide">le_slide 5</span>
    </div>
  </div>
  <a id="prev" class="control prev"></a>
  <a id="next" class="control next"></a>
</div>

In the JSFiddle code you've created: HTML has 在您创建的JSFiddle代码中:HTML具有

<div id="le_le_slider" class="le_le_slider">

and Javascript points to it with 'getElementById' 并且Javascript使用“ getElementById”指向它

var le_le_slider = document.getElementById('le_le_slider'),

Each slider needs it's own ID on the HTML page _ and to be controlled in the Javascript with the same ID 每个滑块需要在HTML页面_上拥有自己的ID,并在具有相同ID的Javascript中进行控制

I cannot find any documentation online for the slider that you are using_ to point you to the instructions for how to code multiple LeLeSliders _ 我找不到您正在使用的滑块的在线文档,无法将您指向有关如何对多个LeLeSliders进行编码的说明_

If this is the case then you should consider using a different slider which has the documentation connected to it that will help you create more than one slider _ Perhaps Slick Slider would suit your needs better >> https://kenwheeler.github.io/slick/ 如果是这种情况,那么您应该考虑使用其他滑块,该滑块上已连接了文档,可以帮助您创建多个滑块_也许Slick Slider会更适合您的需求>> https://kenwheeler.github.io/光滑/

This link goes to a Codepen example of multiple Slick sliders in action on the same page >> https://codepen.io/glebkema/pen/bWRZzB 此链接转到在同一页面上运行的多个Slick滑块的Codepen示例>> https://codepen.io/glebkema/pen/bWRZzB

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM