
Fabrice Innocent
Full Stack JavaScript Techdegree Student 9,715 PointsNext steps with setting the class attribute
A bit confused here. I'm assuming I should be building upon each steps code, so how do I assign a new attribute to the newParagraph variable if I have to already assign it to the "p" variable?
let p = document.createElement('p');
let att = document.createAttribute('panel');
att.value = 'panel';
var contentDiv = document.getElementById('content');
var newParagraph = p;
newParagraph.setAttributeNode('panel')
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<link rel="stylesheet" href="style.css" />
<body>
<div id="content">
</div>
<script src="app.js"></script>
</body>
</html>
1 Answer

Armin Kadic
11,032 Pointsvar contentDiv = document.getElementById('content');
var newParagraph = document.createElement("p"); /* Create it right away without making an individual variable for it */
newParagraph.className = "panel"; /* Add/change the class name to "panel" */
contentDiv.appendChild(newParagraph); /* Attach the new paragraph to the desired node. */
Hope this helps!
Fabrice Innocent
Full Stack JavaScript Techdegree Student 9,715 PointsFabrice Innocent
Full Stack JavaScript Techdegree Student 9,715 PointsThanks so much! Will be going back over the videos to make sure I grasp the concept a bitt better