20
loading...
This website collects cookies to deliver better user experience
DOM is an API for HTML or XML documents and it creates a logical structure which can be accessed and manipulated.
<!-- part of the html body -->
<div id="root"></div>
// getting access to the element (DOM node)
const rootElement = document.querySelector("#root");
// now you can modify the element as you please
// modifying style
rootElement.style.color = "red";
// adding children
const paragraph = document.createElement("p");
const text = document.createTextNode("This is a paragraph.");
paragraph.appendChild(text);
rootElement.appendChild(paragraph);
The Shadow DOM API is a key part of this, providing a way to attach a hidden separated DOM to an element.
<ion-button>Default</ion-button>
<ion-button size="small" class="ios button button-small button-solid ion-activatable ion-focusable hydrated">
<button type="button" class="button-native" part="native"><span class="button-inner"><slot name="icon-only"></slot><slot name="start"></slot><slot></slot><slot name="end"></slot></span></button>
Default
</ion-button>
A virtual DOM is a lightweight JavaScript representation of the DOM used in declarative web frameworks such as React, Vue.js, and Elm.
// demo jsx
<div style={{ color: "red" }}>
<h1>Hello world!</h1>
<p>Some random text</p>
</div>
React.createElement(
"div",
{ style: { color: "red" } },
React.createElement(
"h1",
null,
"Hello world!"
),
React.createElement(
"p",
null,
"Some random text"
)
);
I am a beginner, how should I learn Front-End Web Dev?
Look into the following articles:
Would you mentor me?
Sorry, I am already under a lot of workload and would not have the time to mentor anyone.
Would you like to collaborate on our site?
As mentioned in the previous question, I am in a time crunch, so I would have to pass on such opportunities.