mirror of
https://github.com/bendtherules/UiQuestions.git
synced 2026-08-18 22:02:42 +00:00
create-modify-element - Rename to mdx and use Accordion
This commit is contained in:
@@ -6,6 +6,9 @@ title: DOM Manipulation
|
||||
slug: /
|
||||
---
|
||||
|
||||
import Admonition from "../components/Admonition"
|
||||
import Accordion from "../components/Accordion"
|
||||
|
||||
## Finding elements
|
||||
|
||||
### 1. `querySelector()`
|
||||
@@ -20,16 +23,19 @@ document.querySelector(".box"); // returns first div.box
|
||||
document.querySelector(".not-found"); // null
|
||||
```
|
||||
|
||||
:::note Extra
|
||||
<Accordion>
|
||||
<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
|
||||
// Example - div.outer > div.inner
|
||||
outerEle.addEventListener((ev) => {
|
||||
var innerEle = ev.target.querySelector(".inner");
|
||||
})
|
||||
});
|
||||
```
|
||||
:::
|
||||
|
||||
</Admonition>
|
||||
</Accordion>
|
||||
|
||||
[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
|
||||
|
||||
|
||||
### 1. `createElement`
|
||||
Reference in New Issue
Block a user