Professional Documents
Culture Documents
Period 3 Notes: Emphasized Strong Importance
Period 3 Notes: Emphasized Strong Importance
Period 3 Notes: Emphasized Strong Importance
<aside> Container for content not directly related to the main topic
of a document
- HTML guidelines:
- CSS
1. The element selector matches elements with the specified element
names.
Ex: p { color: blue; } selects all p elements.
2. The class selector, specified with a period character followed by the
class name, matches elements that have the specified class name.
Ex: .notice { color: blue; } selects all elements with
a class="notice" attribute.
3. The ID selector, specified with a hash character followed by the ID
name, matches the element that has the specified ID.
Ex: #byLine { color: blue; } selects the element with
the id="byLine" attribute.
4. The descendant selector, specified with a selector followed by a
space and another selector, matches elements that are contained in
other elements.
Ex: h2 em { color: blue; } selects em elements contained
in h2 elements.
5. The pseudo-class selector, specified with a colon character
followed by a pseudo-class name, matches elements based on user
behavior or element metainformation.
Ex: :hover { color: blue; } selects elements under the
mouse cursor.
::selection
::selection Matches the text { background: yellow
selected by user. }
Fonts:
Text properties:
Padding/margins:
Borderstyles:
Media
Description
features
device-height Height of the output device (entire screen)
JAVASCRIPT
Arithmetic
Description Example
operator
// x = 3
x = 1 + 2;
+ Add
// x = 1
x = 2 - 1;
- Subtract
// x = 6
x = 2 * 3;
* Multiply
// x = 0.5
x = 1 / 2;
/ Divide
Arithmetic
Description Example
operator
// x = 0
x = 4 % 2;
% Modulus (remainder)
// x = 2 * 2 * 2 = 8
x = 2 ** 3;
** Exponentiation
// Same as x = x + 1
x++;
++ Increment
// Same as x = x - 1
-- Decrement x--;
// Same as x = x - 2
-= Subtract x -= 2;
from
// Same as x = x * 3
x *= 3;
*= Multiply by
// Same as x = x / 3
x /= 3;
/= Divide by
// Same as x = x % 4
%= Mod by x %= 4;
2 != 3 // true
"bat" != "zoo" // true
!= Inequality
2 === 2 // true
"2" === 2 // false
=== Identity
2 !== 2 // false
"2" !== 2 // true
!== Non-identity
2 < 3 // true
"bat" < "zoo" // true
< Less than
2 <= 3 // true
"bat" <= "bat" // true
<= Less than or equal
3 > 2 // true
"zoo" > "bat" // true
> Greater than
3 >= 2 // true
>= Greater than or equal "zoo" >= "zoo" // true
Logical
Name Description Example
operator
(1 < 2 && 2 < 3) //
true
&& And True if both sides are true
(1 < 2 || 2 < 0) //
true
|| Or True if either side is true
Logical
Name Description Example
operator
Truthy values.
Example Description
if (32) Non-zero number
// Adds 7, 9, 11 starting at
index 2
nums.splice(2, 0, 7, 9, 11);
// nums = [3, 5, 7, 9, 11, 6]
The for-of loop is a simplified for loop that loops through an entire array.
The array name is placed after the of keyword in a for-of loop. Each
time through the loop, the next array element is assigned to the variable
in front of the of keyword.
The Array method forEach() also loops through an array.
The forEach() method takes a function as an argument. The function
is called for each array element in order, passing the element and the
element index to the function.
into substrings.
s = "What?";
s.toLowerCase(); //
toLowerCase() Returns the string converted "what?"
to lowercase characters.
s = "What?";
s.toUpperCase(); //
toUpperCase() Returns the string converted "WHAT?"
to uppercase characters.
MATH
Math.floor(2.9) // 2
floor(x) Returns x rounded down to
the nearest integer
Math.log(Math.E) // 1
log(x) Returns the natural logarithm
of x
Math.max(5, 2, 8, 1)
max(n1, n2, // 8
n3, ...) Returns the largest number
Math.round(3.5) // 4
round(x) Returns x rounded to the
nearest integer
Math.sin(Math.PI) //
0
sin(x) Returns the sine of radians x
Math.sqrt(25) // 5
sqrt(x) Returns the square root of x
The following methods are for creating new nodes or duplicating existing
nodes:
The document method createElement() returns a new element
node, created from a string argument that names the HTML element.
Ex: document.createElement("p") creates a new paragraph
node.
The document method createTextNode() returns a new text node
containing the text specified by a string argument.
Ex: document.createTextNode("Hello there!") creates the
text node with "Hello there!", which can then be appended to an
element node.
The node method cloneNode() returns an identical copy of a DOM
node. The method's boolean argument indicates whether the method
should also clone the node's children.
Ex: x.cloneNode(true) creates an identical tree rooted at x,
but x.cloneNode(false) creates only a single node identical to
x. A common error is to forget to modify any id attributes in the cloned
tree. The cloneNode() method does not ensure that new nodes
have unique id attributes.
Events:
Event phases
Selector
Example Explanation
Type
$("span[id]")
Attribute Selects all <span> that have an id attribute
$("p:first")
Basic filter Selects the first <p> element
$("tr:even")
Selects the first, third, fifth, etc. table rows (zero-
Basic filter
indexed)
Selector
Example Explanation
Type
$("li:eq(1)")
Basic filter Selects the second <li> element (index n)
$("li:last-child")
Child filter Selects the last <li> in each group
$("p:contains('bye')")
Content
Selects all <p> that contain the word "bye"
filter
$("li span")
Hierarchy Selects all <span> that are descendants of <li>