startit/intro_js/index.html

35 lines
903 B
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=<device-width>, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
</div>
<script>
let count = 0;
add('green', 500, "Det", 'span');
add('red', 250, "var", 'div');
add('blue', 600, "en", 'div');
add('rgb(200, 200, 42)', 500, "gang", 'span');
function add(color, size, word, tagName) {
count++;
let existingHtml = document.getElementById('app').innerHTML;
let newHtml = /*HTML*/ `
<${tagName} style="color:${color}; font-size: ${size}%;">
${word}
${count}
</${tagName}>
`;
document.getElementById('app').innerHTML = existingHtml + newHtml ;
}
</script>
</body>
</html>