1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-07-11 00:12:15 +02:00
Files
deka-dom-el/docs/components/examples/elements/native-dom-create.js
2025-03-05 19:29:03 +01:00

19 lines
436 B
JavaScript

// Create element with properties
const button = document.createElement('button');
button.textContent = "Click me";
button.className = "primary";
button.disabled = true;
// Or using Object.assign()
const button2 = Object.assign(
document.createElement('button'),
{
textContent: "Click me",
className: "primary",
disabled: true
}
);
// Add to DOM
document.body.appendChild(button);
document.body.appendChild(button2);