Skip to content

Instantly share code, notes, and snippets.

@ervinne13
Last active February 3, 2019 08:11
Show Gist options
  • Save ervinne13/42723490c861eaca3ec10b6a7df15179 to your computer and use it in GitHub Desktop.
Save ervinne13/42723490c861eaca3ec10b6a7df15179 to your computer and use it in GitHub Desktop.
Refactoring JavaScript: Separation of Concerns - Markup Code on JS
// ... variable declaration and setting of widgetID, widgetTitle, etc.
let widgetText = "JavaScript is Quirky";
let widgetHTML = '<div id=' + widgetId + '>' +
'<h2 id="' + widgetTitleId + '">' + widgetTitle + '</h2>' +
'<div id="' + widgetContentId + '" style="' + widgetContentStyles + '">' +
widgetText +
'</div>' +
'</div>';
document.getElementById("widget-container").innerHTML = widgetHTML;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment