<div class="comment" data-id="187">
<a class="comment-edit">Редактировать</a>
<span class="comment-panel"></span>
</div>
.comment .comment-panel {
display: none;
}
.comment.editing .comment-panel {
display: inline;
}
.comment.editing .comment-edit {
color: red;
}
const containerSelector = '.comment';
const buttonSelector = '.comment-edit';
const activeClass = 'editing';
// вот вам ваш jquery
$(containerSelector).on('click', buttonSelector, e => {
const id = $(e.delegateTarget).toggleClass(activeClass).data('id');
console.log(id);
});
// или, к чёрту jquery
document
.querySelectorAll(`${containerSelector} ${buttonSelector}`)
.forEach(n => n.addEventListener('click', onClick));
function onClick() {
const container = this.closest(containerSelector);
container.classList.toggle(activeClass);
const { id } = container.dataset;
console.log(id);
}
<div class="icon"></div>
.icon {
font-size: 60px;
display: inline-block;
border: 0.1em solid black;
border-radius: 0.5em;
width: 1em;
height: 2em;
position: relative;
}
.icon::before {
content: "";
display: inline-block;
position: absolute;
width: 0.2em;
height: 0.2em;
background: black;
left: 50%;
top: 30%;
transform: translateX(-50%);
box-shadow: 0 -0.4em black, 0 0.4em black;
}
.icon::after {
content: "";
display: inline-block;
border: 0.15em solid black;
border-left: 0;
border-top: 0;
width: 0.4em;
height: 0.4em;
position: absolute;
top: 60%;
left: 50%;
transform: translateX(-50%) rotate(45deg);
}
filter: drop-shadow()
.linear-gradient
или использоватьborder-image
. Если осёл нужен, но фон однотонный - просто перекрыть угол с тенью. $('.list-item').filter((i, n) => $(n).data('pagereview') !== $(n).data('pageslug')).hide();
$('[data-pageslug]').each(function() {
const $this = $(this);
$this.toggle($this.attr('data-pagereview') === $this.attr('data-pageslug'));
});
document.querySelectorAll('.list-item').forEach(n => {
n.hidden = n.getAttribute('data-pagereview') !== n.getAttribute('data-pageslug');
});
for (const { style, dataset } of document.getElementsByClassName('list-item')) {
if (dataset.pagereview !== dataset.pageslug) {
style.display = 'none';
}
}
.hidden {
display: none;
}
const items = document.querySelectorAll('[data-pageslug]');
for (let i = 0; i < items.length; i++) {
const { classList: c, attributes: a } = items[i];
c.toggle('hidden', a['data-pagereview'].value !== a['data-pageslug'].value);
}
navigationItems.sort(mySortFunc)
function mySortFunc(itemA, itemB) {
return itemA.id - itemB.id
}