Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery步骤<;a href>;触发片_Jquery_Jquery Plugins - Fatal编程技术网

jquery步骤<;a href>;触发片

jquery步骤<;a href>;触发片,jquery,jquery-plugins,Jquery,Jquery Plugins,我正在使用一个在线测验工具,我想知道是否有可能像我粘贴的演示中看到的那样,有一个链接或按钮触发点击标签事件 HTML: <section id="basic"> <h2 class="page-header">Basic Example</h2> <div id="wizard-1"> <h3>Keyboard</h3> <section>

我正在使用一个在线测验工具,我想知道是否有可能像我粘贴的演示中看到的那样,有一个链接或按钮触发点击标签事件

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>
$("#wizard-1").steps({
    headerTag: "h3",
    bodyTag: "section",
    transitionEffect: "slideLeft",
    autoFocus: true
});
如果您将标题/选项卡悬停,您将看到附加到标题/选项卡的锚定。我想做的是调用锚点(即下面的锚点),并使选项卡功能就像我单击了选项卡本身一样

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

JSFiddle

谢谢

根据,到目前为止,它似乎缺少该功能:

/*
*按索引设置特定的步骤对象。
*  
*@方法设置步骤
*@param index{Integer}属于步骤位置的整数
*@param step{Object}要更改的step对象
*
*/
$.fn.steps.setStep=函数(索引,步骤)
{
抛出新错误(“尚未实现!”);
};


由于它还不允许您转到特定步骤,因此下面介绍如何从锚调用确实存在的方法:


HTML


JQUERY解释
a[id$=step]

选择id以
步骤
结尾的所有锚定标记

$(this.attr(“id”).split(“-”)[0]


从单击的锚标记中提取id,在
-
上拆分字符串,并返回第一部分,
previous
next
,这是传递到
步骤
插件以触发相应的previous或next方法所需的字符串。

我找到了一种更简单的解决方法。 只要知道要显示的步骤,就可以使用这个jquery函数来执行单击操作

$("#Donation-t-2").get(0).click();

此示例将显示步骤中的第三张幻灯片

您所做的非常有帮助,但这并不是我想要的。我希望能够指出我希望它进入的具体步骤,而不是通过这些步骤。我想我需要找出每个选项卡的ID,以便能够进行与上一个/下一个按钮相同的调用。谢谢你!问题是,无论出于何种原因,该插件的作者决定不公开
goToStep
方法。如果您查看代码,您可以看到当单击选项卡时,它会调用该私有方法。所以也许你可以自己去实现它。是的,我注意到了,但我想也许有一种方法可以绕过它…比如为私有方法创建一个替换的公共方法?
var $wizard = $("#wizard-1");

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

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