Write a Javascript program which uses DOM properties and methods to insert a new
ID: 3704026 • Letter: W
Question
Write a Javascript program which uses DOM properties and methods to insert a new paragraph with each button click as shown below.
CNN.com-Ex br Tiger Woodsx "we understa x ?????? ??? ??C D file:///HyCST6305/Lectures/NewStuff/JS/Example/Lab-13.html This is a paragraph. This is another paragraph. CI Insert New Paragraph br Tiger we com ? ? C D file:///H:/CST6305/Lectures/NewStuff/JS/Example/Lab-13.html This is a paragraph. This is another paragraph. 1. This is a new paragraph. Insert New Paragraph we understa x ???????? ???? CNN.com-E x bir Tiger Woods x Lab CN C file:///H:/CST6305/Lectures/NewStuff/JS/Example/Lab-13.html This is a paragraph. This is another paragraph. 1. This is a new paragraph. 2. This is a new paragraph. Insert New ParagraphExplanation / Answer
<!DOCTYPE html>
<html>
<head>
<style>
ol
{
margin-left: -25px
}
li
{
margin: 1em 0;
}
</style>
</head>
<body>
<p> This is a paragraph </p>
<p> This is another paragraph </p>
<ol id="ordered-list">
</ol>
<button>Insert New Paragraph</button>
<script type="text/javascript">
function myFunction() {
var listElement = document.createElement("LI");
var listText = document.createTextNode("This is a new paragraph");
listElement.appendChild(listText);
document.getElementById("ordered-list").appendChild(listElement);
}
</script>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.