【问题标题】:jQuery dynamic div sliderjQuery 动态 div 滑块
【发布时间】:2013-09-04 02:56:35
【问题描述】:

由于某种原因,我很难找到这个......

基本上是在寻找一个 jquery 滑块插件(带有下一个和上一个按钮),其中的内容可以是任何东西(div、文本、图像、组合等)。问题来了,我的内容将被动态添加,例如,如果我有类似的东西

<ul>
    <li> /* some divs, images, etc*/ </li>
    <li> /* some divs, images, etc*/ </li>
    <li> /* some divs, images, etc*/ </li>
</ul>

然后我可以动态添加“

  • " 标记到 "" 通过 javascript,这不会破坏滑块。

    我目前正在使用easy slider,但它并不真正支持滑块的内容为“动态”

    提前致谢。

  • 【问题讨论】:

    • 有很多可选的滑块,​​看看这个basic-slider.com很简单
    • 谢谢。我知道有很多,我尝试过很多。但这与另一个有相同的问题,当您动态添加“
    • ”标签时它会搞砸。

    标签: jquery jquery-plugins jquery-slider


    【解决方案1】:

    试试这个

    这是为下一个上一个创建滑块的自定义方式

    jQuery.fn.extend({
      slideRightShow: function(speed) {
        return this.each(function() {
            $(this).show('slide', {direction: 'right'}, +speed || 1000);
        });
      },
      slideLeftHide: function(speed) {
        return this.each(function() {
          $(this).hide('slide', {direction: 'left'}, +speed || 1000);
        });
      },
      slideRightHide: function(speed) {
        return this.each(function() {
          $(this).hide('slide', {direction: 'right'}, +speed || 1000);
        });
      },
      slideLeftShow: function(speed) {
        return this.each(function() {
          $(this).show('slide', {direction: 'left'}, +speed || 1000);
        });
      }
    });
    

    Try This Fiddle

    【讨论】:

      猜你喜欢
      相关资源
      最近更新 更多
      热门标签