Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检测divjquery中的所有更改_Javascript_Jquery_Html_Rich Text Editor - Fatal编程技术网

Javascript 检测divjquery中的所有更改

Javascript 检测divjquery中的所有更改,javascript,jquery,html,rich-text-editor,Javascript,Jquery,Html,Rich Text Editor,我正在做一件事。我想捕获在div中所做的所有更改。 我讨论了一些堆栈溢出问题,如, 这些问题用于在发生更改时获取信息,但我需要了解div中所有更改的详细信息,如添加或删除的任何文本以及在什么位置等。 需要位置和值,以便我可以将其用于我的算法 var editorText = $(".jqte_editor").html(); //editorText = "This is a simple editor" //Convert text into array var array = editorT

我正在做一件事。我想捕获在div中所做的所有更改。
我讨论了一些堆栈溢出问题,如,
这些问题用于在发生更改时获取信息,但我需要了解div中所有更改的详细信息,如添加或删除的任何文本以及在什么位置等。
需要位置和值,以便我可以将其用于我的算法

var editorText = $(".jqte_editor").html();
//editorText = "This is a simple editor"
//Convert text into array
var array = editorText.match(/.{1,5}/g);

var newText = "is not";
var position = 2;

//Add new text and again split it if size is more than 5
if(newText.length > 5)
{
    var newArray = abc.match(/.{1,5}/g);

    for(var i=0;i<newArray.length;i++)
    {
            array.splice(position+i, 0, newArray[i]);
    }

    array.splice(pos-1, 1);
}   

console.log("Array after rendering"+array);
var editorText=$(“.jqte_editor”).html();
//editorText=“这是一个简单的编辑器”
//将文本转换为数组
var数组=editorText.match(/.{1,5}/g);
var newText=“不是”;
var位置=2;
//添加新文本,如果大小大于5,则再次拆分
如果(新文本长度>5)
{
var newArray=abc.match(/.{1,5}/g);

对于(var i=0;i您想实现什么?撤消?版本控制?使用diff将内容发布到服务器?我正在编写自己的diff算法,因此需要知道发生更改的确切位置和更改的值。我正在将文本转换为固定长度的块并将其存储在链接列表中。因此,每当发生更改时,我都需要位置和值因此,该算法使用位置和更新文本进入特定块。创建列表的第二个实例,然后比较这两个列表以找到更改。另外,一些代码也会有所帮助,我不确定我是否理解您的概念。