learning-area
learning-area copied to clipboard
Question: how to handle multiple transcripts on one page
If there are multiple pieces of media on one page, the second transcript doesn't open on click. Is there a way to work around this?
I was trying something like this?
`var transcripts = document.querySelectorAll('.transcript'); var transcriptBtns = document.querySelectorAll('.transcript-container button');
transcriptBtns.forEach(function(transcriptBtn) {
transcriptBtn.addEventListener('click', function() { if(transcriptBtn.textContent === 'Show transcript') { transcripts.style.height = '250px'; transcriptBtn.textContent = 'Hide transcript'; } else { transcripts.style.height = '0'; transcriptBtn.textContent = 'Show transcript'; } };
}`