Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
November 8, 2018 11:44 pm GMT

Get References from HTML Built with Template Literals

One thing JavaScript template literals are great at is little blocks of HTML. Like:

// Probably from some API or whatever
const data = {
title: "Title",
content: "Content"
};

const some_html = `
<div class="module">
<h2>${data.title}</h2>
<p>${data.content}</p>
</div>
`;

But that's still just a string. It's not ready to append to the DOM just yet. And what if we need references to those elements inside somehow?

that are in this vein: lit-html

The post Get References from HTML Built with Template Literals appeared first on CSS-Tricks.


Original Link: https://css-tricks.com/get-references-from-html-built-with-template-literals/

Share this article:    Share on Facebook
View Full Article

CSS Tricks

A Web Design Community curated by Chris Coyier

More About this Source Visit CSS Tricks