Appending Elements Dynamically
The goal of this coding exam is to quickly get you off the ground with Creating and Appending Elements Dynamically with JS.
Use the below reference image.
https://assets.ccbp.in/frontend/content/dynamic-webapps/creating-and-appending-elements-with-js-op.png
HTML
<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="myContainer"></div>
</body>
</html>
CSS Colors used:
Text colors Hex code values used:
#0000ff
<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="myContainer"></div>
<script>
const counterValue = document.querySelector('#myContainer');
const dynElement = document.createElement('h1');
dynElement.innerHTML = 'Main heading element appended dynamically'
dynElement.style.color = '#0000ff';
counterValue.append(dynElement)
</script>
</body>
</html>
Comments
Leave a comment