Ma ktoś pomysł dlaczego poniższy kod może nie działać?
<DOCTYPE html>
<html>
<head>
<title>Real Time Editor</title>
<script type="text/javascript">
function ref(){
var tc = document.getElementById('editor-textarea').value; // <---- To nie działa
document.getElementById('viewer').srcdoc = tc;// <---- To też nie działa
}
</script>
<style>
*{
padding: 0;
margin: 0;
}
.main{
background: #ecf0f1;
width:100%;
height:100%;
display: inline-flex;
}
#editor-textarea{
width:100%;
height:95%;
margin: 10px;
padding: 5px;
}
#viewer{
background: white;
border:none;
width:100%;
height:95%;
margin:10px;
border: 1px solid #3498db
}
</style>
</head>
<body>
<div class="main">
<textarea id="editor-textarea" onkeyup ="ref()" placeholder="Code Here..."></textarea>
<iframe id="viewer"></iframe>
</div>
</body>
</html>