By default IntelliSense in Visual Studio doesn’t know anything about jQuery. So for instance if you try get some help as soon as you type ‘$’ IntelliSense won’t suggest you anything useful.
Enabling support for jQuery is very simple. , but first let’s make sure that we are in the same starting point.
Get jQuery and jQuery documentation for IntelliSense
This is the goal:
How to achieve that?
There are 2 options:
- Create new project in VS 2010 using option ’ASP.NET Web Application’. In Scripts folder you should have jQuery and jQuery IntelliSense documentation already included. (however in version 1.4.2)
- Download manually, the latest files for version jQuery 1.7.2:
How to enable IntelliSense for jQuery
- Create new JScript file, for exampleDefault.js
- Drag & drop jquery-1.4.1-vsdoc.js file into the Default.js file.
when this is done your JS file should loke like this:
/// <reference path="jquery-1.4.1-vsdoc.js" />
- Now you can start using IntelliSense, here are a few examples: