コンテンツへスキップ
ナビゲーションに移動
PAGE TOPdocument.addEventListener('DOMContentLoaded', function () {
console.log('DOM fully loaded and parsed'); // ページ読み込み確認用
if (window.location.search.includes('page_id=4128')) {
console.log('Target page detected'); // ページ確認用
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
console.log('Anchor clicked:', this.getAttribute('href')); // クリック確認用
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
console.log('Target element:', target); // ターゲット要素確認用
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start',
});
const toggleButton = target.querySelector('.vk_accordion-toggle, .vk_accordion-toggle-close');
console.log('Toggle Button:', toggleButton); // トグルボタン確認用
if (toggleButton && toggleButton.classList.contains('vk_accordion-toggle-close')) {
console.log('Condition met: Clicking toggle button');
toggleButton.click();
} else {
console.log('Condition not met');
}
} else {
console.log('Target not found for href:', this.getAttribute('href'));
}
});
});
} else {
console.log('This is not the target page');
}
});