Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript template literals html

// Create our object
const person = {
    name: 'TopCoder2021',
    job: 'Software Developer,
    city: 'Los Angeles',
    bio: 'Tony is a really cool guy that loves to code!'
}

// And then create our markup:
const markup = `
 <div class="person">
    <h2>
        ${person.name}
    </h2>
    <p class="location">${person.city}</p>
    <p class="bio">${person.bio}</p>
 </div>
`;

document.body.innerHTML = markup
Comment

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;
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript import 
Javascript :: redux react redux 
Javascript :: incoroporate js and css file in html 
Javascript :: get only string from html description javascript 
Javascript :: node check if internet 
Javascript :: Nestjs download 
Javascript :: area of a triangle javascript 
Javascript :: reactjs cdn file 
Javascript :: hasownproperty javascript 
Javascript :: fs fstat 
Javascript :: Flatten a multidimension array 
Javascript :: storybook react router 
Javascript :: switch to window in testcafe 
Javascript :: operator to return specific data of a mongodb query 
Javascript :: react native data map is not a function 
Javascript :: js object entries 
Javascript :: javascript find matching elements in two arrays 
Javascript :: loop through nested json object typescript 
Javascript :: The element.parentNode Property 
Javascript :: appendchild javascript 
Javascript :: js html input limit to 5 words 
Javascript :: form-data upload file 
Javascript :: how to insert with variables from js to mysql 
Javascript :: react image source showing object module 
Javascript :: javascript convert utc to local time 
Javascript :: delete file with deno 
Javascript :: react native flatlist container style 
Javascript :: declaring constant in jsx 
Javascript :: discord.js create permanent invite 
Javascript :: javascript prevent iframe interaction 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =