Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

using template literals to create html

const createMarkup = function createMarkup(data) {
  // Just use the same syntax for node elements
  const markup = 
    `<ul id="listItem-${data.name}">
      <li>Name: ${data.name}</li>
      <li>Age: ${data.age}</li>
      <li>Gender: ${data.gender}</li>
      <li>Fav. Colour: ${data.colour}</li>
      <li>Lucky Number: ${data.number}</li>
    </ul>`;return markup;
};
 
PREVIOUS NEXT
Tagged: #template #literals #create #html
ADD COMMENT
Topic
Name
6+6 =