Lesson 2: Working with jQuery CHAPTER 6 291
browser–compatible features that jQuery has. If you need to reference the DOM object from
the jQuery wrapper, you can do it as follows.
var domElement = $('#txtInput')[0];
Don’t forget that you can put this code inside a conditional statement that checks the
length property to see whether an element exists before attempting to access element 0 of
the result.
var domElement;
if($('#txtInput').length > 0){
domElement = $('#txtInput')[0];
}
Enabling JavaScript and jQuery IntelliSense
When learning a new language or library, it’s always good to have some help to keep you
from getting stuck on every statement you write. When you installed jQuery, an IntelliSense
file was added, but it is not yet being used. For example, in the default.js file, if you type a
jQuery expression that includes a selector and then press the Period key, you would like to
see a valid list of available methods and properties. Before setting up IntelliSense, Figure 6-12
shows an example of what you see in the IntelliSense window when you type in a jQuery
expression with a selector and press Period.
FIGURE 6-12 he IntelliSense window when not properly set up for jQueryT