How do I build a site that allows me to code html in it. Where I can type code in a textarea and get the entire output for that code beside the textarea in which I code?
            Asked
            
        
        
            Active
            
        
            Viewed 71 times
        
    0
            
            
        - 
                    this question will help you. https://stackoverflow.com/questions/939326/execute-javascript-code-stored-as-a-string – moe asal Dec 06 '20 at 14:17
2 Answers
2
            
            
        You can use JavaScript; create an id for the button and a div to display the text when the button is clicked:
<html>
<head>
    <title>background</title>
    <style type="text/css">
    
        #text{
            display:none;
        }
    
    </style>
</head>
<body>
    <div id="text">
        My Name Is Anurag.
    </div>
        
    <button id="click">click</button>
        
    <script type="text/javascript">
        document.getElementById("click").onclick= function(){
            var text= document.getElementById("text")
            if(text.style.display=="none"){
                text.style.display="block";
            }else{
                text.style.display="none";
            }
        }
    </script>
</body>
</html>
 
    
    
        user4157124
        
- 2,809
- 13
- 27
- 42
 
    
    
        Anurag Hale
        
- 133
- 9
1
            
            
        document.getElementById("click").onclick = function() {
  var textDiv = document.getElementById("text")
  var textarea = document.getElementById("textarea");
  textDiv.innerText = textarea.value;
}<div id="text">
  Here comes text from textarea
</div>
<textarea id="textarea"></textarea>
<button id="click">click</button> 
    
    
        Velid Duranović
        
- 182
- 3
- 
                    Thanks a lot, but I've already tried this, it works perfectly, but was wondering if there was a way to allow me to use the and tags in this. I'm not if you can do that? – Coolsugar Dec 08 '20 at 01:51
- 
                    Not sure if I understand your question. but I put the code above on stackblitz so you can see it with **** and **** tags. https://stackblitz.com/edit/js-thbwsx?file=index.html – Velid Duranović Dec 08 '20 at 16:58
