-4

How to create ID in myFunction() , im using javascript file. cuz javascript need single string for call html script in variable. cmiiw.

Sample code:

<button class="tablinks" onclick="openFolder(event, 'Folder1')">Folder 1</button>
Calvin Ananda
  • 1,440
  • 1
  • 14
  • 30

1 Answers1

0

Your question is more like: How do I use quotes inside quotes. The solution is to use single quotes if you want double quotes in the string, and double quotes if you want single quotes in the string.

'<button class="tablinks" onclick="openFolder(event, '+'"Folder1")">Folder 1</button>'

alternatively use backticks; template literals https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals making the task much easier:

`<button class="tablinks" onclick="openFolder(event, 'Folder1')">Folder 1</button>`
George
  • 2,330
  • 3
  • 15
  • 36