skip to Main Content

How can I write a JavaScript variable inside double quotation marks in a template literal?

I have this code: const newDiv = document.createElement('div'); newDiv.innerHTML = ` <button class='btn btn-download'> <span class='icon'>⇩</span> Download Subtitle </button> <span>as</span> <select id=`outputFormatSelectId`> <option value="text">Text</option> <option value="text-with-time">Text with Time</option> <option value="json">JSON</option> <option value="srt">SRT</option> </select>`; Notice <select id="outputFormatSelectId"> has a id outputFormatSelectId.…

VIEW QUESTION
Back To Top
Search