Using the Selectors API (^) ❘ 31
.addClass('exampleLinkAutoTarget');
break;
} } } } ) }
);
The preceding code, all put together, should look something like what you see in Figure 2-1.
FIGURE 2-1
When you click a link to an external website in the example, you see those links open in a new win-
dow or tab, depending on how you have your browser’s preferences set up to handle new windows.
In the preceding example, you use JavaScript to force the links in the
- element with the id name
exampleFavoriteLinks to open in a new window or tab. To do this, in the JavaScript, you wrote a bit
of jQuery that is executed at the document ready event.
$(document).ready(
function()
{