More actions
Created page with "// quickLinkCardClick.js (function () { // Wait until the DOM is fully loaded document.addEventListener('DOMContentLoaded', function () { document.querySelectorAll('.vh-quick-link-card').forEach(card => { const link = card.querySelector('a'); if (!link) return; card.addEventListener('click', function (e) { // Avoid double-activating if user clicks directly on the <a> if ( e.target.tagName.toLowerCase() === 'a' ||..." |
(No difference)
|
Revision as of 04:17, 23 July 2025
// quickLinkCardClick.js
(function () {
// Wait until the DOM is fully loaded
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.vh-quick-link-card').forEach(card => {
const link = card.querySelector('a');
if (!link) return;
card.addEventListener('click', function (e) {
// Avoid double-activating if user clicks directly on the <a>
if (
e.target.tagName.toLowerCase() === 'a' ||
e.target.closest('a')
) return;
window.location.href = link.href;
});
// Accessibility: allow Enter/Space key activation
card.setAttribute('role', 'link');
card.setAttribute('tabindex', '0');
card.addEventListener('keydown', function (e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
window.location.href = link.href;
}
});
});
});
})();