Home » News » Intellisense for jQuery on Visual Studio

Intellisense for jQuery on Visual Studio

Hi guys,

This post is for all WebDevs that use Visual Studio as web development tool.
Who never needed to develop something using jQuery and questioned yourself why Visual Studio Intellisense doesn’t work for jQuery?
Sometimes we make small mistakes while developing with jQuery, and those little mistakes makes you remember that if we had intellisense we might not do some errors, or even think that if we had intellisense we could know which functions jQuery have. Well, I will give a tip that can help on this question.

I will use Visual Studio 2010 and jQuery to demonstrate how to use Visual Studio intellisense for jQuery codes.

Let’s do it!
Firstly, on my web project I added a folder called JavaScript with a sub-folder called jQuery, and this folder have our jQuery file (jquery-1.7.2.js), on my JavaScript folder I created my file “Suzuki.js”, see below:

jQuery Intellisense Visual Studio Solution Explorer

Now on my Suzuki.js file, we will create our jQuery code. If we simply try to call the ready function, we can see that intellisense doesn’t show this function.

jQuery Intellisense Visual Studio Not Working

To activate the intellisense for jQuery, we need to drag and drop the jquery-1.7.2.js file  from our solution explorer inside our file Suzuki.js (open file). Once you have done that you will see that Visual Studio will create the following command.

/// <reference path="jQuery/jquery-1.7.2.js" />

jQuery Intellisense Visual Studio Reference

Done! Now we have intellisense for jQuery working on our Visual Studio for this file (Suzuki.js specifically).
Now if we try to use the ready function again we will see the function on intellisense:

jQuery Intellisense Visual Studio Working

You can get jQuery on this link – http://jquery.com.

Thanks for reading.
Like and Share if you found it may be useful to someone you know!

Would you like to check the Portuguese version?
Click on the Brazilian flag -> Brazil

 

 

Deixe um comentário