Unable to assign paragraph element to the given variable
As shown in the code, I have to create a paragraph element and assign it to variable newParagraph. I tried using document.getElementById , getElementsByTagName('p') and getElementsByClassName (I gave the tag some id and class). I was able to manipulate the element using .style and everything. However, I am unable to complete the task. When I click on 'Check Work', I get an error saying "Make sure that you assign a '<p>' element to 'newParagraph'." Please help me solve this problem.
var contentDiv = document.getElementById('content'); var newParagraph = document.querySelector('p');
<!DOCTYPE html> <html> <head> <title>DOM Manipulation</title> </head> <link rel="stylesheet" href="style.css" /> <body> <div id="content"> <p>Hello</p> </div> <script src="app.js"></script> </body> </html>
Daniel TuratoJava Web Development Techdegree Graduate 30,086 Points