javascriptprogress-baruse-strict

Use strict mode on Progress bar


Progress bar is working If I put it directly in the index.html page. But it isn't working (animation) if I put it in external active.js file with "use strict" mode. But Other JS is working fine. Please Help me. Thanks in advance. Here is my code below:

 $('[data-toggle="tooltip"]').tooltip({
                trigger: 'manual'
            }).tooltip('show');


        $(window).on('scroll', function () {
            if ($(window).scrollTop() > 500) { // scroll down abit and get the action   
                $(".progress-bar").each(function() {
                    each_bar_width = $(this).attr('aria-valuenow');
                    $(this).width(each_bar_width + '%');
                });

            }
        });
Details code here: https://codepen.io/valencia123/pen/aOopQx

Solution

  • In 'use strict' mode you have to declare every used variable first. From your snippet it's not obvious that each_bar_width is being declared anywhere. Try with var or const declaration.