Skip to content

Instantly share code, notes, and snippets.

@fragje
Created May 1, 2015 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fragje/f5d49d530eaeec8bc80f to your computer and use it in GitHub Desktop.
Save fragje/f5d49d530eaeec8bc80f to your computer and use it in GitHub Desktop.
Update list - js
// console log history
var el = document.getElementById("accordion-1").children[0].childNodes[0]
undefined
el
"2015
"
typeof el
"object"
el.nodeValue = 2016
2016
el.nodeValue = 20176
20176
el.nodeValue
"20176"
type of el.nodeValue
VM1452:2 Uncaught SyntaxError: Unexpected identifierInjectedScript._evaluateOn @ VM42:883InjectedScript._evaluateAndWrap @ VM42:816InjectedScript.evaluate @ VM42:682
typeof el.nodeValue
"string"
typeof el
"object"
var ancor = document.createElement("a")
undefined
anchor.setAttribute("href", "")
undefined
anchor
<a href>​2015
​</a>​
el.nodeValue = "2000"
"2000"
el.nodeValue = anchor
<a href>​2015
​</a>​
el.nodeValue = anchor
<a href>​2015
​</a>​
el.nodeValue
"http://pwyp.gh.front.no/"
el.insertBefore(anchor)
VM1895:2 Uncaught TypeError: Failed to execute 'insertBefore' on 'Node': 2 arguments required, but only 1 present.(anonymous function) @ VM1895:2InjectedScript._evaluateOn @ VM42:883InjectedScript._evaluateAndWrap @ VM42:816InjectedScript.evaluate @ VM42:682
anchor
<a href>​2015
​</a>​
el
"http://pwyp.gh.front.no/"
el.nodeValue = "";
""
var el2 = document.getElementById("accordion-1").children[0]
undefined
el2
<li>​…​</li>​
el2.insertBefore(anchor)
VM2354:2 Uncaught TypeError: Failed to execute 'insertBefore' on 'Node': 2 arguments required, but only 1 present.(anonymous function) @ VM2354:2InjectedScript._evaluateOn @ VM42:883InjectedScript._evaluateAndWrap @ VM42:816InjectedScript.evaluate @ VM42:682
el2.appendChild(anchor)
<a href>​2015
​</a>​
document.getElementById("accordion-1").children[0]
<li>​…​</li>​
el2
<li>​…​</li>​
el
""
var parent = document.getElementById("accordion-1")
undefined
parent
<ul class=​"list-accordion js-accordion" id=​"accordion-1">​…​</ul>​
parent.insertBefore(anchor, el2)
<a href>​2015
​</a>​
parent.insertBefore(anchor, el)
VM2742:2 Uncaught DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.(anonymous function) @ VM2742:2InjectedScript._evaluateOn @ VM42:883InjectedScript._evaluateAndWrap @ VM42:816InjectedScript.evaluate @ VM42:682
el
""
el2
<li>​…​</li>​
getElementById("accordion-1")
VM2886:2 Uncaught ReferenceError: getElementById is not defined(anonymous function) @ VM2886:2InjectedScript._evaluateOn @ VM42:883InjectedScript._evaluateAndWrap @ VM42:816InjectedScript.evaluate @ VM42:682
document.getElementById("accordion-1")
<ul class=​"list-accordion js-accordion" id=​"accordion-1">​…​</ul>​
document.getElementById("accordion-1")children[1]
VM2908:2 Uncaught SyntaxError: Unexpected identifierInjectedScript._evaluateOn @ VM42:883InjectedScript._evaluateAndWrap @ VM42:816InjectedScript.evaluate @ VM42:682
document.getElementById("accordion-1").children[1]
<li>​…​</li>​
document.getElementById("accordion-1").children[2]
<li>​…​</li>​
document.getElementById("accordion-1").children[0]
<li>​""<ul style=​"display:​ block;​">​…​</ul>​</li>​
document.getElementById("accordion-1").children[0].children
[<ul style=​"display:​ block;​">​…​</ul>​]
document.getElementById("accordion-1").children[0].children[0]
<ul style=​"display:​ block;​">​…​</ul>​
var sibling = document.getElementById("accordion-1").children[0].children[0]
undefined
el2.insertBefore(anchor, sibling)
<a href>​2015
​</a>​
el
""
el.nodeValue = "hello"
"hello"
el.de
undefined
el.deleteData
function deleteData() { [native code] }
el.deleteData()
VM3157:2 Uncaught TypeError: Failed to execute 'deleteData' on 'CharacterData': 2 arguments required, but only 0 present.(anonymous function) @ VM3157:2InjectedScript._evaluateOn @ VM42:883InjectedScript._evaluateAndWrap @ VM42:816InjectedScript.evaluate @ VM42:682
el.remove
function remove() { [native code] }
el.remove()
undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment