startit/intro_js/index.html

29 lines
800 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>
add('green', 500, "Det", 'div');
add('red', 250, "var", 'h3');
add('blue', 600, "en", 'li');
add('rgb(200, 200, 42)', 500, "gang", 'span');
function add(color, size, word, tagName) {
let existingHtml = document.getElementById('app').innerHTML;
let newHtml = /*HTML*/ `
<${tagName} style="color:${color}; font-size: ${size}%;">${word}</${tagName}>
`;
document.getElementById('app').innerHTML = existingHtml + newHtml ;
}
</script>
</body>
</html>