Skip to content

Instantly share code, notes, and snippets.

@huseyinyilmaz
Created January 23, 2019 17:23
Show Gist options
  • Save huseyinyilmaz/daa21e359753ca849e4446f54d01580d to your computer and use it in GitHub Desktop.
Save huseyinyilmaz/daa21e359753ca849e4446f54d01580d to your computer and use it in GitHub Desktop.
VgYPgV
<html>
<body>
<div class="givva" data-uid="23179deb-2160-0f01-986d-c9cd54c163cd"></div>
<body>
</html>
document.addEventListener(
"DOMContentLoaded",
() => {
const el = document.querySelector('.givva');
if (!el) {
console.log('Cannot find root element with .givva class');
} else {
const uid = el.getAttribute('data-uid');
if (!uid) {
console.log('Element with .givva class do not have data-uid attribute.');
} else {
el.innerHTML = ('uid found: ' + uid);
console.log('Write completed successfully');
}
}
});
.givva {
background-color: blue;
color: white;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment