Jump to content

Get Progress to work based on Page on


danjapro

Recommended Posts

We are trying to get progress bar to place active class on the current page it one based on variable being set on page called "page", also the page is written into the <body class="page"> tag, once it is loading the page.

 

It is not working as we need can anyone, help us with script below to set progress bar to do prev and next?????

 

So variable is:

 

 
var page = "refundstep1";

 

Body Class tage looks like:

 

<body class="refunStep 1 main-layout">

 

 

Progress bar is:

 

<div class="tabContent progress-bar hidden-phone">
                
                  <div class="step active">
                    <h2>Step 1: Enter your Pin</h2>
                  </div>
                
                  <div class="step inactive">
                    <h2>Step 2: Tell us your address</h2>
                  </div>
                
                  <div class="step inactive">
                    <h2>Step 3: Confirm Your Details</h2>
                  </div>
                
</div>

 

 

Code to actual set the other list next as class="inactive", list passed or compelted as class="active done", Current page as class="active"

 

var progressClass = $('.progress-bar div.step');
$(progressClass).addClass(function(index, activeClass) {
    var activeClass = 'done';
var activePage = 'active';
alert(page);
var currentPage = page;
var pageClass = $('body').hasClass(page);
console.log(pageClass);
    if(pageClass === true) {
 progressClass.addClass(activePage);
 progressClass.prevAll().addClass(activeClass);
 //To select all next elements of `.progressClass` element:
     progressClass.nextAll().addClass(nopageClass);
    }
    return nopageClass;
  }); 
 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.