1

私が今持っているコードは非常に単純です:

// JS doc
$(document).ready(function(e) {
    $("#id_input").keyup(function(e) {
        var val = $("#id_input").val();
        $("#id_output").val(val);
    });

});

shift+enter を押して入力に改行を入れると、出力に改行が入るように改善しようとしています。そのままでは、コードに改行があると思いますが\n、入力に ctrl+enter の目的の出力である はありません。

http://jsfiddle.net/hD8CF/3/

4

2 に答える 2

1

これは、新しい行をブレークnl2brとして表示するために必要なものです。

于 2012-10-20T00:30:31.233 に答える
0

http://jsfiddle.net/hD8CF/10/ puts the <pre> tag into the equation.

The key line change is here: $("#id_output").html("<pre>" + val + "</pre>");

Another comment mentions adding <pre></pre> to the HTML and targeting that for the output.

You can see a working draft of that on jquery: http://jsfiddle.net/fqX8c/. Please like his comment, above. Also, I have code that sends the text as an object, on defocus, which is useful in other ways; unfortunately for me, it uses knockback, and I use jQuery and mooTools. I'll be trying to translate it to jQuery. http://jsfiddle.net/hD8CF/18/, working version: http://jsfiddle.net/hD8CF/20/: educational version

于 2012-10-20T00:38:56.770 に答える