【发布时间】:2017-12-05 12:26:30
【问题描述】:
如果我将它直接放在 index.html 页面中,进度条正在工作。但是,如果我将它放在具有“使用严格”模式的外部 active.js 文件中,它就不起作用(动画)。但其他 JS 工作正常。请帮我。提前致谢。 下面是我的代码:
$('[data-toggle="tooltip"]').tooltip({ 触发器:'手动' }).tooltip('show'); $(window).on('scroll', function () { if ($(window).scrollTop() > 500) { // 向下滚动并获取操作 $(".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
【问题讨论】:
-
什么不完全有效?您能否提供更多代码,例如 index.html 中的进度条?
-
动画不工作。这里是详细代码codepen.io/valencia123/pen/aOopQx
-
看起来它在 codepen 中对我来说工作正常,但这可能是 codepen 的错。尝试在 each_bar_width 之前添加“var”,看看是否有帮助。
-
谢谢你!它现在可以工作了:)
标签: javascript progress-bar use-strict