79810421

Date: 2025-11-05 17:44:13
Score: 1.5
Natty:
Report link

Although @certainperformance answer shows a solution it does not answer OP's root question:

Why is the IDE showing it? The code works, I'm wondering why it is invalid.

jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:

As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated (mostly because they can lead to incorrect assumptions about the method's behavior).

There is also

but it is deprecated as of jQuery 1.8 and was removed in jQuery 3.0. It was removed because:

when multiple functions are added via successive calls to this method, they run when the DOM is ready in the order in which they are added. As of jQuery 3.0, jQuery ensures that an exception occuring in one handler does not prevent subsequently added handlers from executing. ~ jQuery docs

Related question: Why "$().ready(handler)" is not recommended?

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • User mentioned (1): @certainperformance
  • Looks like a comment (1):
  • High reputation (-1):
Posted by: Prolog