关于Todoism编辑条目问题


#1

问题一:点击条目编辑按钮,条目前面和后面各多出了几个空格,怎么回事?


问题二:以下两句什么意思?什么用?

        var strLength = $edit_input.val().length * 2;
        $edit_input[0].setSelectionRange(strLength, strLength);

源码:

    $(document).on('click', '.edit-btn', function () {
        var $item = $(this).parent().parent();
        var itemId = $item.data('id');
        var itemBody = $('#body' + itemId).text();
        $item.hide();
        $item.after(' \
                <div class="row card-panel hoverable">\
                <input class="validate" id="edit-item-input" type="text" value="' + itemBody + '"\
                autocomplete="off" autofocus required> \
                </div> \
            ');

        var $edit_input = $('#edit-item-input');
        var strLength = $edit_input.val().length * 2;

        $edit_input.focus();
        $edit_input[0].setSelectionRange(strLength, strLength);

        $(document).on('keydown', function (e) {
            if (e.keyCode === ESC_KEY) {
                remove_edit_input();
            }
        });

        $edit_input.on('focusout', function () {
            remove_edit_input();
        })
    });