Lesson 5 Dom manipulate Task 7
by fristyr
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id="application">
<color green>Я зеленый</color>
<color red>Я красный</color>
<color blue>Я голубой</color>
</div>
</body>
</html>
JavaScript
const arr = document.querySelectorAll('color')
for(let i = 0; i<arr.length; i++) {
arr[i].outerHTML = '<span style="color:'+ arr[i].attributes[0].name +'">'+arr[i].textContent+'</span>'
}