Tips on jQuery development in WebStorm

Hi JavaScript devs!

There’s no doubt that everyone is using one or another library to access/manipulate the DOM, and jQuery is currently the most popular one. And WebStorm has lots of small but really neat features to help you coding. Let’s quickly get a feeling of what we have.

1. Selecting DOM elements

The first thing you usually do is selecting some DOM element(s), right? WebStorm will help you with completion for the most used selector types, such as elements ID-s:

or CSS classes:

Sure you can use more complex selectors, which are also supported, like mixed matching:

or parent-child selectors.

Or you can switch to “chained calls” style – no problem!

Since most of jQuery selectors follow CSS selectors syntax, WebStorm will support you writing any valid CSS fragment, providing live code checking and completion.

Side note: if you’re using Dojo toolkit or prototype.js library you will get the same functionality for selecting DOM elements.

2. Element manipulation

Once selected, you may want to check or tweak elements styles using jQuery’s neat hasClass/addClass/removeClass/toggleClass helpers. Needless to say, our IDE will remind you all the jQuery functions names with the bold highlight:

then give an insight on method parameters:

Great! Now WebStorm can help you with the CSS classes themselves:

By the way, you can instantly have all the official docs for any jQuery function in context just by using External documentation action (Shift+F1):

In WebStorm, there are tons of helpful features packed: navigating through the code and inspecting it, checking for errors and potential problems, code refactorings etc. etc. Just keep following this blog as we will show you lot more cool stuff soon!

All the features are available in the latest WebStorm and PhpStorm EAP builds and in all the other products based on IntelliJ IDEA platform.

As usual: feel free to report any problems that you have in bug tracker. We will instantly answer all your questions at the forum.

Happy coding!
JetBrains Web IDE Team

This blog is permanently closed.

For up-to-date information please follow to corresponding WebStorm blog or PhpStorm blog.

 
This entry was posted in Cool Feature, PhpStorm, WebStorm and tagged , , , , . Bookmark the permalink.

15 Responses to Tips on jQuery development in WebStorm

  1. Ka says:

    webstorm only ? I’ve tried phpstorm ps-121.12 and doesn’t work for all these features.

    • Alexey Gopachenko says:

      As article states “All the features are available in the latest WebStorm and PhpStorm EAP builds and in all the other products based on IntelliJ IDEA platform”.

      Have you added JQuery library to the project?…

      • Orillian says:

        I’m in the same boat. I have my jQuery library added, but not seeing any of these cool new features.

  2. Henry says:

    First of all, great product!

    Does this work for external js files?

  3. gtraxx says:

    Is this feature available in 4.3 phpstorm ?
    Best regards

  4. ksafonov says:

    @Henry @Karlheinz Do you mean standalone JavaScript files? Yes it does.

  5. Rafi B says:

    Guys, read the article. It’s jQuery features for web/phpStorm latest EAP. (Not 4.x)

  6. Yoosuf says:

    woow, cool features

  7. ksafonov says:

    @gtraxx @Rafi B Indeed, some of the shown features are part of 4.x release.

  8. Thomas P. says:

    Good idea

  9. Antonio says:

    I did everything as suggested, added the jquery library to the project but still I’m not able to use the auto completion like you show in this post blog.
    The more i try the more it does not work, can you help me to solve this problem?

  10. Yury says:

    It seems that in PhpStorm this works for HTML files, but does not work for PHP files.
    For example, if you need to create an HTML page with PHP inserts—you will not be able to use these selectors. But for HTML it works as promised.

  11. Evan says:

    Selecting the DOM doesn’t work.I have the latest version and Both latest jquery.js and Prototype.js.The methods worked only after i have attached the Jquery.js file in the javascript library and made it public.Go to file>settings>javascript>Libraries and click add.Then click attach and attach the js file and make it public.That should do the trick.

Comments are closed.