Created
July 11, 2016 11:44
-
-
Save flugsio/83ca2ac8e78ef70e4de44371150655e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>title</title> | |
<style type="text/css"> | |
.cssContent::before { | |
content: 'textFromCssContent'; | |
} | |
</style> | |
<script> | |
function createButton() { | |
var text = document.createElement("i"); | |
text.setAttribute("class", "cssContent"); | |
var button = document.createElement("button"); | |
button.appendChild(text); | |
return button; | |
} | |
function createWrapper() { | |
var handler = document.createElement("div"); | |
handler.onmousedown = render; | |
handler.appendChild(createButton()); | |
handler.appendChild(createButton()); | |
var wrapper = document.createElement("div"); | |
wrapper.appendChild(handler); | |
wrapper.id = "wrapper"; | |
return wrapper; | |
} | |
function render() { | |
var old_wrapper = document.getElementById("wrapper"); | |
old_wrapper.parentNode.replaceChild(createWrapper(), old_wrapper); | |
} | |
</script> | |
</head> | |
<body onload="render();"> | |
<div id="wrapper"> | |
<!-- This is what render() produces | |
<div onmousedown="render();"> | |
<button> | |
<i class="cssContent"></i> | |
</button> | |
<button> | |
<i class="cssContent"></i> | |
</button> | |
</div> | |
--> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment