USE;Dynamic Event Listeners
Achieve the given functionality.
CSS Colors used:
Text colors Hex code values used:
#0000ff
<!DOCTYPE html>
<html>
<head></head>
<body>
  <button onclick="createHeading()">create</button>
  <div id="myContainer"></div>
  <script>
  function createHeading() {
    const container = document.querySelector('#myContainer');
    const element = document.createElement("h1");
    element.style.color = "#0000ff";
    element.innerHTML = "My element inside the container";
    container.append(element)
  }
  </script>
</body>
</html>
Comments
Leave a comment