Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP DOMNode insertAfter?

I am a bit stuck on how to reorder nodes. I am trying to add two simple "move item up" and "move item down" functions. While insertBefore() does what I want to move a sibling before the preceding one, what is the easiest way to move one node down in the DOM? Much appreciated!

like image 295
Erik Pöhler Avatar asked Apr 24 '14 15:04

Erik Pöhler


1 Answers

Code Example:

 try {
        $li->parentNode->insertBefore( $ul, $li->nextSibling);
 } catch(\Exception $e){
        $li->parentNode->appendChild( $ul );
 }
like image 200
Layke Avatar answered Oct 07 '22 00:10

Layke