JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JavaScript и jQuery - Глава 5</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/c05.css">
</head>
<body>
<div id="page">
<h1 id="header">Список</h1>
<h2>Продовольственная лавка</h2>
<ul>
<li id="one" class="hot"><em>свежий</em> инжир</li>
<li id="two" class="hot">кедровые орешки</li>
<li id="three" class="hot">пчелиный мед</li>
<li id="four">бальзамический уксус</li>
</ul>
</div>
<script src="js/node-list.js"></script>
</body>
</html>
CSS
@import url(http://fonts.googleapis.com/css?family=Marmelad&subset=latin,cyrillic);
body {
background-color: #000;
font-family: 'Marmelad', 'Futura', sans-serif;
margin: 0;
padding: 0;}
#page {
background-color: #403c3b;
margin: 0 auto 0 auto;}
/* Responsive page rules at bottom of style sheet */
h1 {
background-image: url(../images/kinglogo.png);
background-repeat: no-repeat;
background-position: center center;
text-align: center;
text-indent: -1000%;
height: 75px;
line-height: 75px;
width: 117px;
margin: 0 auto 0 auto;
padding: 30px 10px 20px 10px;}
h2 {
color: #fff;
font-size: 24px;
font-weight: normal;
text-align: center;
text-transform: uppercase;
letter-spacing: .2em;
margin: 0 0 23px 0;}
h2 span {
border-radius: 50%;
background-color: #000;
font-size: 10px;
text-align: center;
display: inline-block;
position: relative;
top: -5px;
height: 18px;
width: 20px;
margin-left: 5px;
padding: 4px 0 0 4px;}
ul {
background-color: #584f4d;
border:none;
padding: 0;
margin: 0;}
li {
background-color: #ec8b68;
color: #fff;
border-top: 1px solid #fe9772;
border-bottom: 1px solid #9f593f;
font-size: 24px;
letter-spacing: .05em;
list-style-type: none;
text-shadow: 2px 2px 1px #9f593f;
height: 50px;
padding-left: 1em;
padding-top: 10px;}
.hot {
background-color: #d7666b;
color: #fff;
text-shadow: 2px 2px 1px #914141;
border-top: 1px solid #e99295;
border-bottom: 1px solid #914141;}
.cool {
background-color: aqua;
color: #fff;
text-shadow: 2px 2px 1px #3b6a5e;
border-top: 1px solid #7ee0c9;
border-bottom: 1px solid #3b6a5e;}
.complete {
background-color: #999;
color: #fff;
background-image: url("../images/icon-trash.png");
background-position: right, right;
background-repeat: no-repeat;
border-top: 1px solid #666;
text-shadow: 2px 2px 1px #333;}
li a {
color: #fff;
text-decoration: none;
background-image: url("../images/icon-link.png");
background-position: center,...
JavaScript
var i = 0;
var hotItems = document.getElementsByClassName('hot'); // Сохраняем NodeList в массиве
if (hotItems.length > 0) { // Если в NodeList есть элементы
while(i<hotItems.length) { // Обрабатываем их все при помощи цикла
hotItems[i].className = 'cool'; // Изменяем значение атрибута class
i++;
}
}
var four = document.querySelector('li#four');
four.textContent = 'COUNT: ' + hotItems.length;