jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery-steps触发标签大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 http://www.jquery-steps.com/Examples#basic作为在线测验工具,并且想知道是否可以使用链接或按钮触发我在粘贴的演示中看到的单击标签事件.

HTML:

<section id="basic">
    <h2 class="page-header">Basic Example</h2>
    <div id="wizard-1">
        <h3>Keyboard</h3>
        <section>
            <p>Try the keyboard navigation by clicking arrow left or right!</p>
        </section>

        <h3>Effects</h3>
        <section>
            <p>Wonderful transition effects.</p>
        </section>

        <h3>Pager</h3>
        <section>
            <p>The next and prevIoUs buttons help you to navigate through your content.</p>
        </section>
    </div>
</section>

JS:

$("#wizard-1").steps({
    headerTag: "h3",bodyTag: "section",transitionEffect: "slideLeft",autoFocus: true
});

如果您将标题/标签悬停,则会看到附加到它们的锚点.我想做的是调用锚点(即下面)并使用tab功能,就像我单击了选项卡本身一样.

<a href="#wizard-1-h-2">Step 3 or Pager</a>

JSfiddlehttp://jsfiddle.net/fXF6k/1/

谢谢!

解决方法

基于 documentation,它似乎缺乏现在的功能

/*  
 * Sets a specific step object by index.  
 *  
 * @method setStep  
 * @param index {Integer} An integer that belongs to the position of a step  
 * @param step {Object} The step object to change  
 *
 */
$.fn.steps.setStep = function (index,step) 
{
    throw new Error("Not yet implemented!"); 
};

由于它还不允许您转到特定步骤,因此您可以在此处调用锚点中存在的方法

See working jsFiddle demo

HTML

<a id="prevIoUs-step" href="#">PrevIoUs</a>
<a id="next-step" href="#">Next</a>

我用上面的替换你的锚标签.

JQUERY

var $wizard = $("#wizard-1");

$wizard.steps
({
    headerTag: "h3",autoFocus: true
});

$("a[id$=step]").on("click",function (e)
{
    e.preventDefault();
    $wizard.steps( $(this).attr("id").split("-")[0] );
});

JQUERY EXPLANATION

一个[ID $=工序]

选择id为以step结尾的所有锚标签.

$(这).attr( “ID”)分割( “ – ”)[0]

从单击的锚标记中拉出id,将字符串拆分为 – 并返回第一个部分,上一个或下一个,最后是传递到steps插件以触发相应的上一个或下一个方法所需的字符串.

大佬总结

以上是大佬教程为你收集整理的jquery-steps触发标签全部内容,希望文章能够帮你解决jquery-steps触发标签所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: