Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS - Simulate .prev() using jqLite only?

In angular.element there is only a next() method but prev(). Is there any way to simulate the behavior of prev() with Angular/jqLite only?

like image 906
gsklee Avatar asked Jul 04 '13 07:07

gsklee


1 Answers

You can also use native DOM api to get previous/next sibling:

var prevNode = element[0].previousElementSibling;
var prev = angular.element(prevNode); // optional

var nextNode = element[0].nextElementSibling;
var next = angular.element(nextNode); // optional
like image 194
Andriy Horen Avatar answered Nov 01 '22 03:11

Andriy Horen