.parent:hover .element{
background: red;
}
.element:hover ~ .element{
background: black;
}
var arr = [
{ price: 10, amount: 10 },
{ price: 12, amount: 12 },
{ price: 9, amount: 7 },
{ price: 17, amount: 8 },
{ price: 4, amount: 2 }
]
arr
.sort(function(a, b) {
return a.price - b.price
})
.reverse()
.map(function(item, i) {
item.index = i + 1
})
console.log(arr)
/*
[
{ price: 17, amount: 8, index: 1 },
{ price: 12, amount: 12, index: 2 },
{ price: 10, amount: 10, index: 3 },
{ price: 9, amount: 7, index: 4 },
{ price: 4, amount: 2, index: 5 }
]
*/
var sorted = products.sort((curr, prev)=>{
if (curr.price > prev.price) return 1
if (curr.price < prev.price) return -1
return 0
})
https://jsfiddle.net/0v0vhrqu/ <div class="section">
<div class="title">
<h2>Заголовок</h2>
<div class="title__subtitle">Подзаголовок</div>
</div>
<div class="inner features">
<div class="features__item">
<div class="block">
<div class="block__icon">
<img class="block__image" src="images/icon1.png" alt="" />
</div>
<div class="block__text">Текст текст текст текст текст</div>
</div>
</div>
<div class="features__item">
<div class="block">
<div class="block__icon">
<img class="block__image" src="images/icon1.png" alt="" />
</div>
<div class="block__text">Текст текст текст текст текст</div>
</div>
</div>
</div>
</div>
/* Cookie function */
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}
if (getCookie('isVisited')) {
// меняем CSS
} else {
// Устанавливаем куки
document.cookie = 'isVisited=true; path=/';
}