mirror of https://github.com/4xmen/xshop.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
853 B
JavaScript
23 lines
853 B
JavaScript
2 days ago
|
document.addEventListener('DOMContentLoaded',function () {
|
||
|
document.querySelectorAll('.v-main-category')?.forEach(function (el) {
|
||
|
el.addEventListener('click',function () {
|
||
|
document.querySelectorAll('.v-item').forEach(function (elm) {
|
||
|
elm.style.display = 'none';
|
||
|
});
|
||
|
// Get the element to be displayed
|
||
|
const targetId = el.getAttribute('data-id');
|
||
|
const targetElement = document.querySelector(targetId);
|
||
|
|
||
|
if (targetElement) {
|
||
|
targetElement.style.display = 'block';
|
||
|
|
||
|
// Scroll to the element
|
||
|
targetElement.scrollIntoView({
|
||
|
behavior: 'smooth', // Smooth scroll effect
|
||
|
block: 'start' // Scroll to the top of the element
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
});
|