<div class="portfolio__gallery-filters">
<a class="portfolio__gallery-filter portfolio__gallery-filter-all">
<i class="icon-th"></i></a>
<a class="portfolio__gallery-filter" href="#tab-business">Business</a>
<a class="portfolio__gallery-filter" href="#tab-corporate">Corporate</a>
<a class="portfolio__gallery-filter" href="#tab-photography">Photography</a>
<a class="portfolio__gallery-filter" href="#tab-branding">Branding</a>
</div>
var filterButtons = $(".portfolio__gallery-filters a"); //Получение массива со всеми кнопками
for (i = 0; i < filterButtons.length; i++) {
filterButtons[i].click(function (e) { //Обработчик клика для каждой кнопки
e.preventDefault();
console.log(this.getAttribute('href'));
});
}
$(".portfolio__gallery-filters a").click(function() {
var $this = $(this);
console.log($this.attr('href'));
return false;
});
// js
let filterButtons = document.querySelectorAll(".portfolio__gallery-filters a")
filterButtons.forEach(button => {
button.addEventListener("click", function() {
alert(this.getAttribute("href"))
})
})
// jquery
$(".portfolio__gallery-filters a").click(function(e) {
e.preventDefault();
let href = $(this).attr("href");
alert(href);
})