HTML and CSS Reference
In-Depth Information
To select elements by their tag name, simply use the name of the tag. No special characters are needed:
// Select elements by their tag name.
document.getElementsByTagName(“p"); // Pure JavaScript
$(“p"); // jQuery
jQuery has other nifty selectors that you can use, too. You can find a full list of these on the jQuery website: ht-
tp:// .
Other Benefits of Using jQuery
As well as providing handy ways to select elements, jQuery offers a lot of other useful functions. There are functions
for easily updating the properties and content of elements as well as manipulating CSS styling. There are even func-
tions available to help you add effects such as fades and animations to your web pages. The jQuery library also
provides a series of functions that make it easier to set up event listeners.
One of the biggest benefits of using jQuery is that the library accounts for the inconsistencies in browsers so that you
don't have to. As explained earlier in this topic, some browser vendors decided to implement technologies slightly
differently, whether it is a variation in how a particular function is named or whether a browser vendor decided to in-
clude a function at all. This means that it is often necessary to write multiple variations of the same code in order to
ensure that it will work in all web browsers. The jQuery library takes care of a lot of these inconsistencies for you so
that you can just focus on writing your programs.
That concludes the brief tour of jQuery. If you like the look of jQuery's simpler syntax, check out the documentation
on the jQuery website ( ) .
Congratulations! You just learned the basics of a new programming language.
JavaScript is one of the most important languages for creating modern web applications, especially if you want to
take advantage of the awesome new features introduced in HTML5.
In this chapter, you learned the basics of JavaScript and created a number of programs of varying complexity. You
also learned how the DOM works and what happens to your HTML and CSS code when the browser processes it.
You were introduced to a number of key programming concepts in this chapter, but it takes months (if not years) to
truly master all that JavaScript has to offer. Now that you have the basic foundations in place I recommend that you
explore JavaScript some more by getting a book on the subject or completing the JavaScript courses on Treehouse.
You might want to start with the JavaScript Foundations course at
websites/javascript-foundations .
In the next chapter, you dig into some slightly more advanced HTML5 features, starting with native video and audio.
You learn how to embed videos and audio clips into your web pages and how to use the new skills that you acquired
in this chapter to create custom controls to manage playback.
Search WWH ::

Custom Search