I have created this live-preview thingy that works perfectly, but new lines and so on doesn't show, and also I have a bb-codes function I would my text to go through. So that text in the textarea `[b]Hello world[/b]` is **Hello world**

This is my code so far:

```
<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    </head>
    <body>
        <textarea name="WPcomment" id="WPComment" placeholder="Legg til tekst..."></textarea>
        <br>
        <input type="button" class="button" name="answer" value="Live-preview" onclick="showDiv()" />
        <div style="display:none;" id="prevCom"></div>
    </body>
        <script type="text/javascript">

        var wpcomment = document.getElementById('WPComment');

        wpcomment.onkeyup = wpcomment.onkeypress = function(){
            document.getElementById('prevCom').innerHTML = this.value;
        }

        function showDiv() {
           document.getElementById('prevCom').style.display = "block";
        }

        </script>
</html>

```

Jsfiddle: <https://jsfiddle.net/mhp57cno/>

The php that I use when I output text from my database is this:

```
$htmltext = htmlspecialchars($htmltext);
$htmltext = showBBcodes($htmltext);

echo $htmltext;

```

What I basicly want is the text from `#prevCom` to output as the `$htmltext` from above