It comes down to these lines in the script - specifically the part in red;
Code:
var audio = this.nextSibling;
while (audio.nodeType != 1){ audio = audio.nextSibling; }
"this" is the button element, and "nextSibling" is the audio element - matching the original markup structure where <audio> is the next element after <button>.
Now, with you adding another element between <button> and <audio>, the audio element is no longer nextSibling of the button element, so the original script breaks. But you can adapt it to account for the extra nextSibling (the <span>) - replace the two lines above with these;
Code:
var span = this.nextSibling;
while (span.nodeType != 1){ span = span.nextSibling; }
var audio = span.nextSibling;
while (audio.nodeType != 1){ audio = audio.nextSibling; }
It also means that this line won't work either;
Code:
this.previousElementSibling.className = 'fltlft';
There's another previousElementSibling to account for, so change the line to this;
Code:
this.previousElementSibling.previousElementSibling.className = 'fltlft';
This makes the script work with your markup, providing that all your musical notes and song titles maintain this format;
Code:
<button class="fltlft" title="Play / Pause"></button> <span class="songTitle" title="">When The Stone<br />Was Rolled Away</span>
<audio preload="none">
<source src="music/Stone.mp3" type="audio/mpeg" />
</audio>
The <br/> won't affect the script as its contained within the span.
Bookmarks