(function (Drupal) { const handleExpand = (element) => { const expandElement = element.target.parentElement.querySelector('.to-expand'); if (expandElement.style.display === "inline") { expandElement.style.display = "none"; element.target.innerHTML = Drupal.t('Read more'); } else { expandElement.style.display = "inline"; element.target.innerHTML = Drupal.t('Collapse'); } }; document.querySelectorAll('.expand-link').forEach((element) => { element.addEventListener('click', handleExpand); }); }) (Drupal);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter