Javascript-форум (https://javascript.ru/forum/)
-   Events/DOM/Window (https://javascript.ru/forum/events/)
-   -   TypeError: ххх is not a constructor (https://javascript.ru/forum/events/85012-typeerror-khkhkh-not-constructor.html)

ureech 03.03.2023 20:24

TypeError: ххх is not a constructor
 
Привет.На сайте код работает. Выкладываю на codepan выдаёт ошибку.

<span class="rating big-red" data-default-rating="3" ></span>
<script>
  $(function(){   
            var ratings = document.querySelector('.rating');
            new SimpleStarRating(ratings);         
          });

</script>


script.js

var SimpleStarRating = (function () {
    function SimpleStarRating(target) {
        function attr(name, d) {
            var a = target.getAttribute(name);
            return (a ? a : d);
        }
....
    return SimpleStarRating;
})();


В чём подвох)?

Aetae 04.03.2023 03:46

script.js подключается позже(ниже), чем идёт запрос к SimpleStarRating.

ureech 04.03.2023 06:57

Блин, да вроде пробовал и так и сяк.Наверное не "поймал").


Часовой пояс GMT +3, время: 20:45.