官术网_书友最值得收藏!

Chapter 3. Selecting DOM Elements

In the last chapter, we learned about the MooTools syntax as well as JavaScript best practices. More specifically, we discussed unobtrusive JavaScript and how we should separate our structure (HTML) from our website's behaviors (JavaScript).

In order to successfully and effortlessly write unobtrusive JavaScript, we must have a way to point to the Document Object Model ( DOM) elements that we want to manipulate. The DOM is a representation of objects in our HTML and a way to access and manipulate them. In traditional JavaScript, this involves a lot (like, seriously a lot) of code authoring, and in many instances, a lot of head-banging-against-wall-and-pulling-out-hair as you discover a browser quirk that you must solve.

Let me save you some bumps, bruises, and hair by showing you how to select DOM elements the MooTools way. This chapter will cover how you can utilize MooTools to select/match simple elements (like, "All div elements") up to the most complex and specific elements (like, "All links that are children of a span that has a class of awesomeLink and points to

In this chapter we will look at:

  • The $() and $$() functions
  • Selecting HTML elements with pseudo-class selectors
  • Selecting HTML elements based on their attributes

So let's get on with it!

主站蜘蛛池模板: 五大连池市| 东辽县| 涿鹿县| 尉氏县| 万载县| 建德市| 乐亭县| 都匀市| 鹤壁市| 保亭| 吉安县| 成安县| 岳阳县| 承德县| 获嘉县| 榆林市| 武陟县| 隆昌县| 宣化县| 车险| 东阳市| 民县| 米泉市| 安新县| 策勒县| 武宁县| 诏安县| 抚州市| 宜兴市| 太康县| 旌德县| 黄山市| 彰武县| 辽阳县| 修水县| 辽阳市| 长阳| 若羌县| 平安县| 阳江市| 上饶县|