25

I have the following JavaScript file:

/*global $ */

function foo() {
    'use strict';
    var $tr = $('table tr'),
        $td = $tr.children('td');

    $td.html('Hello World');
}

In PHPStorm, children gets underlined with a weak warning. Mousing over it reveals this message:

Method expression is not of Function type

This file is in the same directory as jquery.min.js (v. 1.11.0, if that matters).

How can I fix this?

Note that the above example is a minimalist example sufficient to reproduce the problem; it's not my actual code, but it will product the same result.

9
  • 1
    are you sure $ is referring to jQuery? can you try var $tr = jQuery('table tr') Commented Oct 24, 2014 at 2:28
  • Okay, this is weird. Yes, I'm sure that's what it refers to in the sense that it definitely refers to jQuery when I run it. But making the change you suggested makes the warning go away in PHPStorm. Any thoughts on why that is? Commented Oct 24, 2014 at 2:39
  • I should point out that my real source code is part of an existing, deployed-in-the-wild project, so I would rather make the warning go away in PHPStorm than change all uses of $ to jQuery. Thanks. Commented Oct 24, 2014 at 2:41
  • 1
    it looks like some king of IDE configuration issue... also see bloglovin.com/… Commented Oct 24, 2014 at 2:50
  • 4
    @JoaoCunha The variable names themselves don't matter; it turns out that I simply needed to include the uncompressed version of jQuery in my project. Commented Oct 24, 2014 at 3:04

3 Answers 3

17

I have my answer thanks to Arun P Johny. I needed to have jquery-1.11.1.js (the uncompressed version) somewhere in my project. I added it, and PHPStorm immediately resolved all jQuery-related warnings.

Sign up to request clarification or add additional context in comments.

1 Comment

Now, 6 years later, we have jQuery 3.5.1 and PhpStorm has it in its cache ~/.config/JetBrains/PhpStorm2020.2/javascript/extLibs/http_ajax.googleapis.com_ajax_libs_jquery_3.5.1_jquery.js is the uncompressed version and it shows this message by $object.fadeOut(1000);- any idea?
1

Another solution would be to add jQuery as a library here:

Settings/Preferences dialog, click JavaScript under Languages and Frameworks, then click Libraries.

1 Comment

Actually, this didn't solve the problem at the time that this occurred. I'm not sure if it would solve the problem with the latest versions of PHPStorm.
-3

This is usually associated with phpstorm so either download and use the Jquery uncompressed version or use Jquery with CDN, it will be resolved.

1 Comment

I solved this question (with help from another user) and posted and accepted my own answer 4.5 years ago. Your answer adds nothing to that answer. And I know the problem is specific to PHPStorm; that’s why I mentioned PHPStorm in my question and my answer and used the PHPStorm tag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.