Yannick
Yannick

Reputation: 3663

Copy to another div as you type in jquery

I'm trying to reproduce the same thing as stackoverflow does when you start typing in the editor it copies.

I have a input text and the text they enter I want it to be copied to another div as they type.

Upvotes: 0

Views: 249

Answers (3)

Nanu
Nanu

Reputation: 3070

$(document).ready(function() {
    $('#input').keyup(function() {
       $('#output').html($(this).val());
    });
});

Upvotes: 0

Dave L.
Dave L.

Reputation: 9791

If you want to reproduce exactly what is here, did you look at the source?

I think this is what they use:

http://code.google.com/p/wmd-new/source/browse/wmd.js

Search in the file for the function pushPreviewHtml. You will see this line which may be of interest:

wmd.panels.output.innerHTML = "<pre><code>" + newText + "</code></pre>";

Upvotes: 0

Kon
Kon

Reputation: 27441

$(document).ready(function() {
    $('#input').keypress(function() {
       $('#output').html($(this).val());
    });
});

Example/demo: http://jsfiddle.net/SYwpy/

Upvotes: 6

Related Questions