¡@

Home 

2014/10/16 ¤W¤È 12:04:37

jquery Programming Glossary: lastnode

Convert delimited string into hierarchical JSON with JQuery

http://stackoverflow.com/questions/6232753/convert-delimited-string-into-hierarchical-json-with-jquery

for var j 0 j chain.length j var wantedNode chain j var lastNode currentNode for var k 0 k currentNode.length k if currentNode.. list of children that has the right name create one if lastNode currentNode var newNode currentNode k name wantedNode children..

Insert html at caret in a contenteditable div

http://stackoverflow.com/questions/6690752/insert-html-at-caret-in-a-contenteditable-div

html var frag document.createDocumentFragment node lastNode while node el.firstChild lastNode frag.appendChild node range.insertNode.. node lastNode while node el.firstChild lastNode frag.appendChild node range.insertNode frag Preserve the selection.. node range.insertNode frag Preserve the selection if lastNode range range.cloneRange range.setStartAfter lastNode range.collapse..

Convert delimited string into hierarchical JSON with JQuery

http://stackoverflow.com/questions/6232753/convert-delimited-string-into-hierarchical-json-with-jquery

input.length i var chain input i .split var currentNode output for var j 0 j chain.length j var wantedNode chain j var lastNode currentNode for var k 0 k currentNode.length k if currentNode k .name wantedNode currentNode currentNode k .children .. k .children break If we couldn't find an item in this list of children that has the right name create one if lastNode currentNode var newNode currentNode k name wantedNode children currentNode newNode.children output JSONifies as name..

Insert html at caret in a contenteditable div

http://stackoverflow.com/questions/6690752/insert-html-at-caret-in-a-contenteditable-div

IE9 for one var el document.createElement div el.innerHTML html var frag document.createDocumentFragment node lastNode while node el.firstChild lastNode frag.appendChild node range.insertNode frag Preserve the selection if lastNode range.. div el.innerHTML html var frag document.createDocumentFragment node lastNode while node el.firstChild lastNode frag.appendChild node range.insertNode frag Preserve the selection if lastNode range range.cloneRange range.setStartAfter.. lastNode while node el.firstChild lastNode frag.appendChild node range.insertNode frag Preserve the selection if lastNode range range.cloneRange range.setStartAfter lastNode range.collapse true sel.removeAllRanges sel.addRange range else..