Game Development Reference
In-Depth Information
Query selectors
If you have been doing any web development at all in the last several years, you've
certainly heard or, used, and have fallen in love with the popular JavaScript lib-
rary jQuery. Among its many powerful features, one of jQuery's most useful tools is
its amazing DOM selector API, which allows you to retrieve the DOM elements by
simply using CSS selectors and pseudo selectors, as opposed to using the limited
document.getElementById() , document.getElementsByClassName() ,
and document.getElementsByName() methods, among other equally limited
ones.
The good news is that this powerful nodes selector API is now all native to modern
browsers. Since the feature is native to the browser, it is much faster and more
stable. Furthermore, since the feature is native to the browser, there is no need to
import a library to handle the task.
This game, as well as all the others described in this topic, uses the new selectors
API level 1. Since there are no visual elements that can be seen form query select-
ors, we'll deepen the discussion about its usage in the next section, where we'll also
take a look at some code examples.
Search WWH ::




Custom Search