On the mobile side, div contenteditable= "true" exceeds the limit on the number of input words and the cursor is positioned at the end after substring intercept.

on the mobile side, there is a div tag that sets contenteditable= "true":

<div class="ipt-multi" contenteditable="true"></div>

when you enter more than 500, add a style (red in color) to the excess number of words

this.contentNode.bind("keyup change", function () {
            var content = self.getContent();
            if (content.length > 500) {
                // 
                if (content.length > self.MAX_CONTENT_LENGTH) {
                    var newContent = content.substring(0, self.MAX_CONTENT_LENGTH) + "<span style="color: -sharpdf0616">" + content.substring(self.MAX_CONTENT_LENGTH, content.length) + "</span>";
                    $(".ipt-multi").focus().html(newContent);
                    self.po_Last_Div($(".ipt-multi"));
                }
            } 
        });

but after typing, the cursor goes to the front, and I try to add a code like this:

po_Last_Div: function(obj) {
            if (window.getSelection) {//ie11 10 9 ff safari
                obj.focus(); //ff
                var range = window.getSelection();//range
                range.selectAllChildren(obj);//range obj
                range.collapseToEnd();//
            }
            else if (document.selection) {//ie10 9 8 7 6 5
                var range = document.selection.createRange();//
                //var range = document.body.createTextRange();
                range.moveToElementText(obj);//rangeobj
                range.collapse(false);//
                range.select();
            }
        },
    

reported the following error:



feedback-min.js:formatted:1006 Uncaught TypeError: Failed to execute "selectAllChildren" on "Selection": parameter 1 is not of type "Node".
at Object.po_Last_Div (feedback-min.js:formatted:1006)
at HTMLDivElement.<anonymous> (feedback-min.js:formatted:992)
at HTMLDivElement.n.proxy (base-min.js:1)

could you tell me how to solve this error so that the cursor can be positioned at the end of the input word limit?

Jun.25,2021

clipboard.png
add "[0]" to fetch object self.po_Last_Div ($(".ipt-multi") [0]);

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3314f-2b6b9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3314f-2b6b9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?