문제

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!

도움이 되었습니까?

해결책

Code Example:

 try {
        $li->parentNode->insertBefore( $ul, $li->nextSibling);
 } catch(\Exception $e){
        $li->parentNode->appendChild( $ul );
 }

다른 팁

Okay, stupid me. The easy solution is to just go down in the DOM to the nextSibling of the nextSibling and do the same insertBefore... so this is solved.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top