简体   繁体   English

jQuery插件-简单功能帮助

[英]jQuery Plugin - simple feature help

I'm using this jQuery Plugin to present a sort of "features list" on a website I'm working on. 我正在使用此jQuery插件在我正在工作的网站上显示某种“功能列表”。 This plugin is pretty straightforward and effectively does just what this demo shows. 这个插件非常简单,可以有效地完成本演示所显示的内容。

There is one piece of functionality I would like to implement in this, however. 但是,我想在其中实现一项功能。 I would like to be able to put a "previous" and "next" link in the content area of each tab, to switch to the, well, previous or next set of content. 我希望能够在每个选项卡的内容区域中放置“上一个”和“下一个”链接,以切换到上一组或下一组内容。

Can anyone offer some help in what should be done to implement this functionality with this jQuery Plugin? 任何人都可以在使用该jQuery插件实现该功能时应提供的帮助方面提供一些帮助吗?

Thanks so much for any assistance you may be able to offer... 非常感谢您可能提供的任何帮助...

You just need to add previous/next links that call .click() (the equivalent of .trigger('click') on the right tab element. 您只需要在右侧选项卡元素上添加调用.click() (等效于.trigger('click')previous/next链接。

Demo → 演示→

Markup, CSS, and JS are identical to the demo linked in the question except for the following: 标记,CSS和JS与问题中链接的演示相同,除了以下内容:

HTML 的HTML

<div id="content">
    <!-- snip, no changes here -->
    <span id="featureNav">
        <a id="prev">&lt; prev</a>
        |
        <a id="next" href="javascript:;">next &gt;</a>
    </span>
</div>

CSS 的CSS

#content {
    position: relative;
}

#featureNav {
    position: absolute;
    bottom: 0;
    right: 0; 
}

JavaScript 的JavaScript

$('#prev').click(function ()
{
    var $current = $('#tabs li a.current'),
        $prev = $current.parent().prev();

    if (!$prev.length)
    {
        $prev = $current.parent().siblings(':last');
    }

    $prev.find('a').click();
});

$('#next').click(function ()
{
    var $current = $('#tabs li a.current'),
        $next = $current.parent().next();

    if (!$next.length)
    {
        $next = $current.parent().siblings(':first');
    }

    $next.find('a').click();
});

If you understand how jQuery plugins are written, it should be quite easy to incorporate this code into the plugin. 如果您了解jQuery插件的编写方式,那么很容易将此代码合并到插件中。 I'm not sure if you wanted a one-off solution, or a change to the plugin itself. 我不确定您是否想要一次性解决方案,还是要更改插件本身。

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

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