当字符大于 10 时如何停止输入?

How to stop typing, when characters is greater than 10?

关注代码:

Html:

<textarea id="summernote">Test</textarea>
<h5 id="limite_vermelho" style="text-align:right;color:red"></h5>
<h5 id="limite_normal" style="text-align:right"></h5>

JS:

$('#summernote').on('summernote.keyup', function(e) {
    var text = $(this).next('.note-editor').find('.note-editable').text();
    var length = text.length;
    var num = 10 - length;

    if (length > 10) {
        $('#limite_normal').hide();
        $('#limite_vermelho').text(10 - length).show();
    }
    else{
        $('#limite_vermelho').hide();
        $('#limite_normal').text(10 - length).show();
    }    
});

或者如果你更喜欢在 jsfiddle 中:https://jsfiddle.net/dtgr5q29/114/

试试这个:
https://jsfiddle.net/dtgr5q29/116/
您只需要插入此代码:

$("#summernote").summernote("code", text.substring(0,10));