I have a list of elements in HTML, like this:
<div>Information Div</div>
<div>Div 1</div>
<div>Div 2</div>
<div>Div 3</div>
What I need to do is move the Information Div
around the DOM, so that it appears after whichever div the user clicks on. So, if the user clicks on Div 1
, the new DOM would look like:
<div>Div 1</div>
<div>Information Div</div>
<div>Div 2</div>
<div>Div 3</div>
This is pretty easy with jQuery, but I gather direct DOM manipulation is frowned upon in Angular. Is there a way of doing this easily with AngularJS?
To add an additional twist, the Information Div
should always appear above the final div, so if the user clicked Div 2
*or Div 3
, the DOM would look like:
<div>Div 1</div>
<div>Div 2</div>
<div>Information Div</div>
<div>Div 3</div>