开发者

Copy to another div as you type in jquery

开发者 https://www.devze.com 2023-03-18 23:07 出处:网络
I\'m trying to reproduce the same thing as stackoverflow does when you start typing in the editor it copies.

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 ty开发者_如何学Pythonpe.


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

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


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>";


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号