javascript og lit css
This commit is contained in:
parent
fcbb649185
commit
fe0b5a944b
8 changed files with 156 additions and 103 deletions
29
intro_js/index.html
Normal file
29
intro_js/index.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!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>
|
Loading…
Add table
Add a link
Reference in a new issue