While working on my video player using dash.js, I encountered an error message saying "Uncaught ReferenceError: Invalid left-hand side in assignment on element attribute" when attempting to include a data attribute in my function for generating the <video>
element within the video-container element.
function createVideoElement() {
videoElement = document.createElement("video");
videoElement.id = "video";
videoContainer = document.getElementById("video-container");
videoElement.autoplay = false;
videoElement.src = "";
videoElement.controls = true;
videoElement.data-video-id = window.datavideoId;
videoContainer.appendChild(videoElement);
window.addEventListener('popstate', onBackNav);
return videoElement;
}
The problematic line is:-
videoElement.data-video-id = window.datavideoId;
Removing the data-video-id line allows for the creation of the <video>
element with all necessary attributes. Any suggestions for incorporating this data attribute without triggering the error?