Tips on jQuery development in WebStorm

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!

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?

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.

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.