Is there a simple way to implement before method for DOM manipulation without jQuery in my AngularJS directive?
jQuery way is:
$element.before($insertedBeforeElement);
To do it without jQuery but with angular's jqLite:
$element.parent()[0].insertBefore($insertedBeforeElement[0], $element[0]);
jqLite does support .after()
so you can use that to do a little shuffling.
$element.after($insertedBeforeElement); //add it after
$insertedBeforeElement.after($element); //now switch the positions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With