diff --git a/docs/create-modify-element.mdx b/docs/create-modify-element.mdx index 78cb9e1..64a7aaf 100644 --- a/docs/create-modify-element.mdx +++ b/docs/create-modify-element.mdx @@ -16,10 +16,10 @@ import Accordion from "../components/Accordion" This method returns the **first element that matches the CSS selector**. If no match is found, it returns `null`. ```js -var ele = document.querySelector(selector); +document.querySelector(selector); -// Ex. - body > div.container > div.box + div.box -document.querySelector(".box"); // returns first div.box +// Ex. - body > div.container > div.box +document.querySelector(".box"); // returns div.box document.querySelector(".not-found"); // null ``` @@ -51,9 +51,9 @@ Here, the NodeList is static - meaning any changes in the DOM later does not aff ::: ```js -var paragraphs = document.querySelectorAll("p"); +var paras = document.querySelectorAll("p"); -for (var p of paragraphs) { +for (var p of paras) { p.className = "note"; } ``` @@ -69,7 +69,7 @@ The `document.createElement` method creates a new HTML element, taking the tag n To set attributes and add the element to DOM, look at `.setAttribute` and `.appendChild` below. ```js -var newEle = document.createElement("div") // creates
+document.createElement("div") // creates ```