Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add "insertBefore" method

  • Loading branch information...
commit 1a0b083a31af4516308a224e2049bf9f1d7dff7a 1 parent e162aa3
@Daniel15 authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 dom.js
View
17 dom.js
@@ -195,6 +195,23 @@
},
/**
+ * Insert a DOM node before node
+ * @method insertBefore
+ * @param {ElementWrapper} Wrapped DOM node
+ * @chainable
+ * @example
+ // Insert a new element before #container
+ var containerEl = $('container');
+ var newEl = DOM.create('div', { id: 'helloWorld' });
+ containerEl.insertBefore(newEl);
+ */
+ insertBefore: function(newNode)
+ {
+ this.element.parentNode.insertBefore(newNode.element || newNode, this.element);
+ return this;
+ },
+
+ /**
* Append some HTML to the element
* @method append
* @param {String} html HTML to append
Please sign in to comment.
Something went wrong with that request. Please try again.