Created
January 19, 2024 08:55
-
-
Save wpgaurav/a8b137cd4b5f2515b4054deedbf4ef92 to your computer and use it in GitHub Desktop.
Fix for Marketers Delight Social Share accessibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', function() { | |
// Find all elements with the class 'share-text' | |
var shareTextElements = document.querySelectorAll('.share-text'); | |
shareTextElements.forEach(function(shareTextElement) { | |
// Find child elements with a class starting with 'md-icon-' | |
var shareIcons = shareTextElement.querySelectorAll('[class*="md-icon-"]'); | |
shareIcons.forEach(function(icon) { | |
// Extract the part of the class name after 'md-icon-' | |
var iconName = icon.className.match(/md-icon-([^\s]+)/); | |
if (iconName && iconName[1]) { | |
// Create a new span element with the class 'hide' | |
var newSpan = document.createElement('span'); | |
newSpan.className = 'hide'; | |
newSpan.textContent = iconName[1]; | |
// Insert the new span before the closing of '.share-text' | |
shareTextElement.appendChild(newSpan); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment