最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Basic jquery Steps Wizard - Stack Overflow

programmeradmin6浏览0评论

Been trying to do this for a while now, but it seems all jquery steps/wizard plugins are very limited and was hoping you guys are able to help me out a little.

What i'm trying to do is a very basic 3 steps wizard via jQuery. So at beginning it only shows the .step-active and .content-active at first and then 2 and then 3 where i submit the form.

Here is my HTML:

<div class="steps-wizard">
<div class="step1 step-active">1</div>
<div class="step2">2</div>
<div class="step3">3</div>
</div>

<form id="steps-form">
<div class="steps-content">
<!-- STEP 1 -->
<div class="step1-content content-active">
    -- CONTENT --
    <a href="#">Next</a>
</div>

<!-- STEP 2 -->
<div class="step2-content">
    -- CONTENT --
    <a href="#">Next</a>
</div>

<!-- STEP 3 -->
<div class="step3-content">
    -- CONTENT --
    <input type="submit">Submit</a>
</div>

Any help on this would be very much appreciated as it seems i'm not able to get this working correctly...

Thanks guys!

Been trying to do this for a while now, but it seems all jquery steps/wizard plugins are very limited and was hoping you guys are able to help me out a little.

What i'm trying to do is a very basic 3 steps wizard via jQuery. So at beginning it only shows the .step-active and .content-active at first and then 2 and then 3 where i submit the form.

Here is my HTML:

<div class="steps-wizard">
<div class="step1 step-active">1</div>
<div class="step2">2</div>
<div class="step3">3</div>
</div>

<form id="steps-form">
<div class="steps-content">
<!-- STEP 1 -->
<div class="step1-content content-active">
    -- CONTENT --
    <a href="#">Next</a>
</div>

<!-- STEP 2 -->
<div class="step2-content">
    -- CONTENT --
    <a href="#">Next</a>
</div>

<!-- STEP 3 -->
<div class="step3-content">
    -- CONTENT --
    <input type="submit">Submit</a>
</div>

Any help on this would be very much appreciated as it seems i'm not able to get this working correctly...

Thanks guys!

Share Improve this question edited May 7, 2014 at 19:25 Rafael Staib 1,22612 silver badges14 bronze badges asked Jul 10, 2013 at 13:07 Jack JohnsonJack Johnson 6114 gold badges12 silver badges23 bronze badges 4
  • This is effectively just tabbed content, which has plenty of tutorials online or many plugins available from a quick google search – seemly Commented Jul 10, 2013 at 13:12
  • Yes, but i haven't found any that switches tabs with a click of a button and be able to go back... – Jack Johnson Commented Jul 10, 2013 at 13:16
  • @Mazzon, first you should format your HTML properly, to avoid possible problems... do you want navigation to work on upper buttons (1,2,3) and, also on 'next' links? You've mentioned that you want to 'go back' - so, i guess that you need 'prev/next' functionality? – sinisake Commented Jul 10, 2013 at 13:19
  • Simple CSS Steps Wizard: github./shahzadthathal/css-steps-wizard – Muhammad Shahzad Commented Mar 10, 2020 at 7:15
Add a ment  | 

4 Answers 4

Reset to default 3

Yes, it applies to many wizard plugins but not to jQuery Steps. jQuery Steps is a very powerful and feature-rich wizard plugin. There are plenty of CSS classes you can use to customize the control like you want. Each step consists of one step button, a step title (which is hidden by default) and a step panel for the content. In your case you have to override just two CSS classes (see the following CSS snippet).

/* First hide all steps from the begining on */
.wizard > .steps li
{
    display: none;
}

/* Then just re-show only the current step */
.wizard > .steps li.current
{
    display: block;
}

A running demo you find here.

For more information and examples go here.

For a more advanced form wizard implementation go here. There you will learn how to plug jQuery Steps and jQuery Validation together.

I used your HTML code. I added numbers to --CONTENT-- to see what's going on, and added 2 lines of CSS to hide inactive <div>s, but I don't think you really need classes like step3-content.

$(document).ready(function() {
    $('a').click(function(e) {
        // this prevents page reload after clicking <a> 
        e.preventDefault();
        // parent: exact <div> with <a> you just clicked, grandpa: all content <div>s, index: next <div> index
        var parent = $(this).parent('div'), grandpa = $('.steps-content>div'), index = grandpa.index(parent)+1;
        // remove active class from current <div>
        parent.removeClass('content-active');
        // set it to next div
        grandpa.eq(index).addClass('content-active');
        // another way to do the same, but using 1 line and children() instead of '>'
        $('.steps-wizard').children('div').removeClass('step-active').eq(index).addClass('step-active');
    });
    // that's it
});

I think you want something like this:

http://jsbin./egidod/1/

I hope this will help you.

I have only made a simple tab plugin. It uses Jquery UI.

I use JQuery plugin Smart Wizard and it works perfectly. The implementation is very simple. Follow the link to an example and documentation:

https://github./mstratman/jQuery-Smart-Wizard

发布评论

评论列表(0)

  1. 暂无评论