solution for excercise 3
This commit is contained in:
parent
46bd30a722
commit
14a0502b91
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<script type="text/javascript" src="task_3.js"></script>
|
||||||
|
<title>JavaScript</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 id="heading1">JavaScript</h1>
|
||||||
|
<p id="par1">
|
||||||
|
<input type="button" value="add Entry" onclick="loopTen();"/>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,17 @@
|
||||||
|
function loopTen(){
|
||||||
|
for(var i = 1; i < 11; i++) {
|
||||||
|
paragraph = createParagraph("Textabsatz", i);
|
||||||
|
var element = document.getElementById("par1");
|
||||||
|
element.appendChild(paragraph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createParagraph(input, amount) {
|
||||||
|
id = "par" + amount;
|
||||||
|
text = input + amount;
|
||||||
|
var node = document.createTextNode(text);
|
||||||
|
var paragraph = document.createElement("p");
|
||||||
|
paragraph.id = id;
|
||||||
|
paragraph.appendChild(node);
|
||||||
|
return paragraph;
|
||||||
|
}
|
Reference in New Issue