Uncaught TypeError: Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type 'Node'

Kingsley Simon

Running into an error on this Dom manipulation

var prependData = $('#income_ranges').children().first().clone();
var prependedData = $('#income_ranges').children().last();
var list = document.getElementById("income_ranges");
list.insertBefore(prependData, prependedData);

Uncaught TypeError: Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type 'Node'.

I get an error when I run this code and I dont know why. Any help is appreciated.

Anders

Can't test right now, but I am pretty sure that you get this error because you are switching between jQuery objects and vanilla JS objects. Use .get() on a jQuery object to get it's vanilla counterpart (see documentation).

So change the last line to:

list.insertBefore(prependData.get(0), prependedData.get(0));

Or go full jQuery (much prettier in my opinion):

var prependData = $('#income_ranges > :first-child').clone();
var prependedData = $('#income_ranges > :last-child');
prependData.insertBefore(prependedData);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

From Dev

Javascript error: Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'

From Dev

typeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node Polymer

From Dev

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

From Dev

Error: Failed to execute 'insertBefore' on 'Node'

From Dev

Uncaught NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node

From Dev

Getting an error: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

From Dev

Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'

From Dev

Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'. in Chrome

From Dev

Uncaught HierarchyRequestError: Failed to execute 'insertBefore' on 'Node': The new child element contains the parent

From Dev

Angularjs : Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'

From Dev

polymer.html: Uncaught TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'

From Dev

Leaflet.markercluster onclick error - Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

From Dev

Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node' error on append tr to a table

From Dev

jQuery Chosen: Uncaught NotFoundError: Failed to execute 'appendChild' on 'Node':

From Dev

failed to execute appendchild on node

From Dev

Cannot append DOM element to DIV node: Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node'

From Dev

Insert node with insertBefore

From Dev

NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node

From Dev

Failing Angular directive unit test on MutationObserver: parameter 1 is not of type 'Node'

From Dev

Error "Uncaught TypeError: Failed to execute 'animate' on 'Element': Valid arities are: [1], but 4 arguments provided." on dynamic input field

From Dev

OpenShift: "Failed to execute control start" on node application

From Dev

XPath Error in Mink: Failed to execute 'evaluate' on 'Document': The result is not a node set, and therefore cannot be converted to the desired type

From Dev

Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element' - Angular / Ionic kendo-chart

From Dev

Why does insertBefore delete the reference node here?

From Dev

Javascript Handsontable - Uncaught TypeError: Cannot read property 'insertBefore' of undefined

From Dev

Node.js Uncaught TypeError: callback is not a function in process.nextTick

From Dev

JSON node in jquery, Uncaught TypeError: Cannot read property '0' of undefined

From Dev

Node.js Uncaught TypeError: callback is not a function in process.nextTick

Related Related

  1. 1

    Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

  2. 2

    Javascript error: Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'

  3. 3

    typeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node Polymer

  4. 4

    Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

  5. 5

    Error: Failed to execute 'insertBefore' on 'Node'

  6. 6

    Uncaught NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node

  7. 7

    Getting an error: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

  8. 8

    Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'

  9. 9

    Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'. in Chrome

  10. 10

    Uncaught HierarchyRequestError: Failed to execute 'insertBefore' on 'Node': The new child element contains the parent

  11. 11

    Angularjs : Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'

  12. 12

    polymer.html: Uncaught TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'

  13. 13

    Leaflet.markercluster onclick error - Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

  14. 14

    Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node' error on append tr to a table

  15. 15

    jQuery Chosen: Uncaught NotFoundError: Failed to execute 'appendChild' on 'Node':

  16. 16

    failed to execute appendchild on node

  17. 17

    Cannot append DOM element to DIV node: Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node'

  18. 18

    Insert node with insertBefore

  19. 19

    NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node

  20. 20

    Failing Angular directive unit test on MutationObserver: parameter 1 is not of type 'Node'

  21. 21

    Error "Uncaught TypeError: Failed to execute 'animate' on 'Element': Valid arities are: [1], but 4 arguments provided." on dynamic input field

  22. 22

    OpenShift: "Failed to execute control start" on node application

  23. 23

    XPath Error in Mink: Failed to execute 'evaluate' on 'Document': The result is not a node set, and therefore cannot be converted to the desired type

  24. 24

    Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element' - Angular / Ionic kendo-chart

  25. 25

    Why does insertBefore delete the reference node here?

  26. 26

    Javascript Handsontable - Uncaught TypeError: Cannot read property 'insertBefore' of undefined

  27. 27

    Node.js Uncaught TypeError: callback is not a function in process.nextTick

  28. 28

    JSON node in jquery, Uncaught TypeError: Cannot read property '0' of undefined

  29. 29

    Node.js Uncaught TypeError: callback is not a function in process.nextTick

HotTag

Archive