Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/info340/book
Browse files Browse the repository at this point in the history
  • Loading branch information
joelwross committed Feb 23, 2023
2 parents 8dfea40 + d5a4708 commit b05634a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions dom.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ let isThick = document.querySelector('svg rect')

These methods will let you interact with attributes that are _not_ defined by the HTML spec, such as `data-` attribute. However, they _don't_ work with certain element attributes (such as the `value` attribute of an `<input>` element). Other elements may have their own special DOM properties: see the [DOM Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model) for a list of [HTML interfaces](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model#HTML_interfaces).
#### Changing Element CSS
It is possible to modify the **CSS classes** (and even inline styling) of an element. But rather than using the `class` property like with other attributes, you instead access the **`className`** property. On modern browsers (IE 10 or later), this property supports methods `.add()` and `.remove()` for adding and removing classes from the list:
#### Changing Element CSS {-}
It is possible to modify the **CSS classes** (and even inline styling) of an element. But rather than using the `class` property like with other attributes, you instead access the **`classList`** property. On modern browsers (IE 10 or later), this property supports methods `.add()` and `.remove()` for adding and removing classes from the list:
```js
//access list of classes
Expand Down Expand Up @@ -218,7 +218,7 @@ console.log(secondSection); //<section id="second-section"></section>

SVG content doesn't support `parentElement`, but does support `parentNode`.
You can also call methods to create and add new HTML DOM elements to the tree. The `document.createElement()` function is used to create a new HTML element. However this element is _not_ created a part of the tree (after all, you haven't specified where it would put into the page)! Thus you need to also use a method such as `appendChild` to add that new element as a child of another element:
You can also call methods to create and add new HTML DOM elements to the tree. The `document.createElement()` function is used to create a new HTML element. However this element is _not_ created as a part of the tree (after all, you haven't specified where it would put into the page)! Thus you need to also use a method such as `appendChild` to add that new element as a child of another element:

```js
//create a new <p> (not yet in the tree)
Expand Down
4 changes: 2 additions & 2 deletions react-interactive.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Interactive React
This chapter discussed how websites built using the React library can be made interactive, with Components that render different content in response to user actions. Specifically, it details how to idiomatically handle _events_, store dynamic information in a Component's _state_ using _hooks_, as well as perform some specific common interactions (such as using forms and downloading data).
This chapter discussed how websites built using the React library can be made interactive, with Components that render different content in response to user actions. Specifically, it details how to idiomatically handle _events_, store dynamic information in a Component's _state_ using _hooks_, as well as perform some specific common interactions (such as using forms and downloading data)


## Handling Events in React
Expand Down Expand Up @@ -314,7 +314,7 @@ function VotingApp(props) {
);
}

function CandidateButton() {
function CandidateButton(props) {
const handleClick = () => {
//On click, execute the given callback function (passing in own name)
props.callback(props.color)
Expand Down

0 comments on commit b05634a

Please sign in to comment.