Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Stack Overflow mirror what you're typing?

Right now while I'm typing this there's the preview down below the editor. I would like to do something similar. How does Stack Overflow do this?

like image 505
Shawn Avatar asked Jan 24 '23 04:01

Shawn


2 Answers

They use an HTML editor called WMD Markdown Editor.

like image 161
Brandon Avatar answered Mar 08 '23 16:03

Brandon


$(function(){
    // whenever the text in the editor box changes:
    $("#editorTextArea").change(function(){
        // add the text to the preview box below
        // this certainly involves some formatting/marking up of the text
        // but this is good enough for illustrative purposes
        $("#previewBox").val(this.value);
    });
});
like image 27
brettkelly Avatar answered Mar 08 '23 15:03

brettkelly