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:
$( handler )$( document ).ready( handler )$( "document" ).ready( handler )$( "img" ).ready( handler )$().ready( handler )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
$(document).on( "ready", handler )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?