如何在jQuery步骤向导中获取当前步骤?

Pau*_*ulG 4 jquery jquery-steps

我正在寻找一种在jQuery Steps向导中获取当前步骤的方法。如果当前步骤是步骤1,我想执行一个操作。

Chr*_*ris 6

这将以整数形式返回当前步骤索引。

$("#wizard").steps("getCurrentIndex");
Run Code Online (Sandbox Code Playgroud)

此步骤索引从零开始。

因此,要在第一步(我假设您所说的“第一步”是指)上执行一项操作,您应该执行以下操作:

if ( $("#wizard").steps("getCurrentIndex") == 0 ) {
    perform_action();
}
Run Code Online (Sandbox Code Playgroud)

参考:https : //github.com/rstaib/jquery-steps/wiki/Methods


Ale*_*der 2

onStepChangingonStepChanged事件带有currentIndex参数。您可以将操作放在函数内来处理任何这些事件。