.one path {
fill: #909090;
}
.one.active path {
fill: #f00;
}
const itemSelector = '.one';
const activeClass = 'active';
document.addEventListener('click', function(e) {
const el = e.target.closest(itemSelector);
if (el) {
el.classList.toggle(activeClass);
}
});
// или
document.querySelectorAll(itemSelector).forEach(function(n) {
n.addEventListener('click', this);
}, e => e.currentTarget.classList.toggle(activeClass));
const buttonSelector = '.one';
const contentSelector = '.two';
const className = 'three';
document.querySelector(buttonSelector).addEventListener('click', () => {
document.querySelector(contentSelector).classList.toggle(className);
});
document.addEventListener('click', e => {
const button = e.target.closest(buttonSelector);
if (button) {
const index = [...document.querySelectorAll(buttonSelector)].indexOf(button);
document.querySelectorAll(contentSelector)[index].classList.toggle(className);
}
});
// или
const buttons = document.querySelectorAll(buttonSelector);
const contents = document.querySelectorAll(contentSelector);
buttons.forEach(n => n.addEventListener('click', onClick));
function onClick(e) {
const index = Array.prototype.indexOf.call(buttons, e.currentTarget);
contents[index].classList.toggle(className);
}
function connectdb() {
$connect = new mysqli("localhost", "root", "", "rr");
$connect->set_charset( 'utf8');
return $connect;
}
select ROW_NUMBER() over (order by id desc) newID,id,color from
(
select 1 id, 'зеленый' color
union all select 2, 'красный'
union all select 3, 'синий'
union all select 4, 'белый'
) yourtable
order by id
<div id="box"><div onclick="add(1,this.id);">Поднимающийся див</div></div>
$strings = ['one', 'two', 'three', 'four', 'five']; //массив строк
$p_array = []; // массив выбранных строк
for ($i = 0; $i < 2; $i++) {
//Элементы не будут повторятся. Если нужно, чтобы элементы повторялись - нужно юзать array_rand
$p_array[] = pop(array_shuffle(&$strings)); //собственно выбираем случайный элемент
}
$peremennaya = implode("\n", $p_array); //имплодим через нужный разделитель