0

My following code gives the error message this is not a function (see code-snippet line 8). How do I correctly call it then?

((e) => {
  if(e.children == null || e.children.length == 0) return;
  e = e.children;
        
  $(e).each( (i, o) => {
    console.log(o);
    this(o);
  })

})(document.body);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

3
  • 2
    you'll have to give the function a name Commented Aug 22, 2022 at 14:23
  • Which function are you expecting to be this? They're both arrow functions, for one thing, which don't have their own this: stackoverflow.com/q/24900875/3001761. Commented Aug 22, 2022 at 14:26
  • Why do you have that odd mix of vanilla JS and jQuery? Commented Aug 22, 2022 at 14:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.