mirror of
https://github.com/bendtherules/UiQuestions.git
synced 2026-08-18 13:52:50 +00:00
create-modify-element - Rename to mdx and use Accordion
This commit is contained in:
@@ -6,6 +6,9 @@ title: DOM Manipulation
|
|||||||
slug: /
|
slug: /
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Admonition from "../components/Admonition"
|
||||||
|
import Accordion from "../components/Accordion"
|
||||||
|
|
||||||
## Finding elements
|
## Finding elements
|
||||||
|
|
||||||
### 1. `querySelector()`
|
### 1. `querySelector()`
|
||||||
@@ -20,16 +23,19 @@ document.querySelector(".box"); // returns first div.box
|
|||||||
document.querySelector(".not-found"); // null
|
document.querySelector(".not-found"); // null
|
||||||
```
|
```
|
||||||
|
|
||||||
:::note Extra
|
<Accordion>
|
||||||
This method is also available on all DOM nodes. If you want to look within a specific element, this is very useful.
|
<Admonition type="note" title="Extra">
|
||||||
|
This method is also available on all DOM nodes. If you want to look within a specific element, this is very useful.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Example - div.outer > div.inner
|
// Example - div.outer > div.inner
|
||||||
outerEle.addEventListener((ev) => {
|
outerEle.addEventListener((ev) => {
|
||||||
var innerEle = ev.target.querySelector(".inner");
|
var innerEle = ev.target.querySelector(".inner");
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
:::
|
|
||||||
|
</Admonition>
|
||||||
|
</Accordion>
|
||||||
|
|
||||||
[Read on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector)
|
[Read on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector)
|
||||||
|
|
||||||
@@ -57,5 +63,4 @@ for (var p of paragraphs) {
|
|||||||
|
|
||||||
## Create / insert element
|
## Create / insert element
|
||||||
|
|
||||||
|
### 1. `createElement`
|
||||||
### 1. `createElement`
|
|
||||||
Reference in New Issue
Block a user