Complete not working?

  • 0
    var el=document.querySelectorAll('.bigslider .slider__item img')
    for (let i=0; i<=el.length;i++ ){
    	if (el[i].complete) {
    		var tmp=get_dimensions(el[i]);
    	else {
    		el[i].onload=function(event) {
    			event=event || window.event;
    			var || event.srcElement;
    			var tmp=get_dimensions(el);<code lang="javascript">

    When I load only one element, everything works fine, I load the array there and call the function for each element one by one, I don’t like this line of code if (el [i] .complete) I know why ..., like I also give only one element and gives this error
    review.js:197 Uncaught TypeError: Cannot read property 'complete' of undefined
    JavaScript Anonymous, Mar 20, 2019

  • 2 Answers
  • 0
    First, there is a direct road to figuring out how to get the last element of an array.

    i & lt; = el.length;

    Second, like Roman said, you overwrite el if:

    !! el [i] .complete === false.
    Felix Caldwell

  • 0
    i & lt; = el.length-1

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!