إنشاء عدات في صفحة html in javascript

<!DOCTYPE html>
<html>
<body>

<p>Click the button to create a custom element object.</p>

<button onclick="createCustomElement()">Create Element</button>

<script>
function createCustomElement() {
  // Create a new custom element
  var myElement = document.createElement("custom-element");
  
  // Add some text to the custom element
  var node = document.createTextNode("This is a custom element");
  myElement.appendChild(node);
  
  // Append the custom element to the body of the page
  document.body.appendChild(myElement);
}
</script>

</body>
</html>
559 chars
25 lines

related categories

gistlibby LogSnag